Skip to content

[Feature request] Global Data helper, if the path doesn't exist, create it. #83

@DineshSolanki

Description

@DineshSolanki

Is your feature request related to a problem? Please describe.
currently, I have to manually create the path first before using a custom name with the path that might not exist already.

Describe the solution you'd like

public override string FileName { get; set; } =
         Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"foo","bar","AppConfig.json");

if the above folders. foo & bar does not exist, Data helper should create them, before creating AppConfig.json.

Additional context
This method might come in handy

public static void CreateFile(string fullFilePath)
        {
            var fileName = Path.GetFileName(fullFilePath);
            var pathWithoutFileName = fullFilePath.Replace(fileName, "");
            Directory.CreateDirectory(pathWithoutFileName);
            if (string.IsNullOrEmpty(fileName))
				fileName = "AppConfig.json";
            File.Create(Path.Combine(pathWithoutFileName, fileName));
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions