123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.IO;
- public static class FileManager
- {
-
-
-
-
-
- public static string ReadFile(string filePath)
- {
- if (!File.Exists(filePath))
- {
- WriteFile("[]", filePath);
- return "[]";
- }
-
- return File.ReadAllText(filePath);
- }
-
-
-
-
-
- public static void WriteFile(string str, string filePath)
- {
- if (Directory.Exists(filePath) == false)
- {
- DirectoryInfo pathInfo = new DirectoryInfo(filePath);
- pathInfo.Parent.Create();
- }
- File.WriteAllText(filePath, str);
- }
-
-
-
-
-
- public static string CalFilePath(string path)
- {
- if (path.Contains("\\"))
- {
- path = path.Replace("\\", "/");
- }
- return path;
- }
- }
|