private static async Task <byte[]> ReadBytesAsync(string path) { byte[] result; if (path == null) { result = null; } else { path = StorageUtility.ConvertPathSeparators(path); StorageFile storageFile = await StorageFile.GetFileFromPathAsync(path); StorageFile storageFile2 = storageFile; IBuffer buffer = await FileIO.ReadBufferAsync(storageFile2); DataReader var_10 = DataReader.FromBuffer(buffer); try { byte[] var_11_128 = new byte[var_10.get_UnconsumedBufferLength()]; var_10.ReadBytes(var_11_128); result = var_11_128; } finally { int num; if (num < 0 && var_10 != null) { var_10.Dispose(); } } } return(result); }
public static void FileWriteText(string path, string text) { path = StorageUtility.ConvertPathSeparators(path); Task <bool> task = StorageUtility.AsyncFileWriteText(path, text); task.Wait(); }
public static StorageFile GetFile(string path, FileOperationMode mode) { path = StorageUtility.ConvertPathSeparators(path); StorageFile storageFile; try { storageFile = StorageUtility.GetFileFromPath(path); } catch (Exception ex) { if (mode == FileOperationMode.Append || mode == FileOperationMode.Create) { return(StorageUtility.CreateFile(path)); } throw ex; } if (mode == FileOperationMode.Create) { StorageFile storageFile2 = StorageUtility.CreateFileAtPath(StorageUtility.ConvertPathSeparators(Application.temporaryCachePath), "temp", 0); StorageUtility.MoveAndReplaceFile(storageFile2, storageFile); storageFile = storageFile2; } return(storageFile); }
public static void FileWriteLines(string path, string[] contents) { path = StorageUtility.ConvertPathSeparators(path); Task <bool> task = StorageUtility.AsyncFileWriteLines(path, contents); task.Wait(); }
public static void FileDelete(string path) { path = StorageUtility.ConvertPathSeparators(path); Task <bool> task = StorageUtility.FileDeleteAsync(path); task.Wait(); }
public static StorageFolder GetFolderFromPath(string path) { path = StorageUtility.ConvertPathSeparators(path); Task <StorageFolder> task = StorageUtility.AsyncGetFolderFromPath(path); task.Wait(); return(task.Result); }
public static string[] FileReadLines(string path) { path = StorageUtility.ConvertPathSeparators(path); Task <IEnumerable <string> > task = StorageUtility.AsyncFileReadLines(path); task.Wait(); return(task.Result.Cast <string>().ToArray <string>()); }
public static IBuffer FileReadBuffer(string path) { path = StorageUtility.ConvertPathSeparators(path); Task <IBuffer> task = StorageUtility.AsyncFileReadBuffer(path); task.Wait(); return(task.Result); }
public static void FileRename(string sourcePath, string destPath) { sourcePath = StorageUtility.ConvertPathSeparators(sourcePath); destPath = StorageUtility.ConvertPathSeparators(destPath); Task <bool> task = StorageUtility.FileRenameAsync(sourcePath, destPath); task.Wait(); }
private static async Task <string> AsyncReadTextAsync(string path) { path = StorageUtility.ConvertPathSeparators(path); StorageFile storageFile = await StorageFile.GetFileFromPathAsync(path); StorageFile storageFile2 = storageFile; return(await FileIO.ReadTextAsync(storageFile2)); }
public static bool FolderExists(string path) { if (path == null) { return(false); } path = StorageUtility.ConvertPathSeparators(path); Task <bool> task = StorageUtility.FolderExistsAsync(path); task.Wait(); return(task.Result); }
public static StorageFile CreateFile(string path) { path = StorageUtility.ConvertPathSeparators(path); int pathSeparatorIndex = StorageUtility.GetPathSeparatorIndex(path, false); if (pathSeparatorIndex == -1) { throw new Exception("No folder in file path: " + path); } int num = pathSeparatorIndex + 1; StorageFolder storageFolder = null; string text = path; List <string> list = new List <string>(); while (storageFolder == null && pathSeparatorIndex != -1) { text = text.Substring(0, pathSeparatorIndex); pathSeparatorIndex = StorageUtility.GetPathSeparatorIndex(text, false); try { storageFolder = StorageUtility.GetFolderFromPath(text); } catch (Exception var_6_55) { if (pathSeparatorIndex != -1) { list.Add(text.Substring(pathSeparatorIndex + 1)); } storageFolder = null; } } if (storageFolder == null) { throw new Exception("No accesible folder found in path: " + path); } int count = list.Count; if (list.Count > 0) { for (int i = list.Count; i >= 0; i--) { storageFolder = StorageUtility.CreateFolder(storageFolder, list[i]); } } return(StorageUtility.CreateFile(storageFolder, path.Substring(num))); }
public static string CreateFolderAtPath(string path) { path = StorageUtility.ConvertPathSeparators(path); while (StorageUtility.IsPathSeparator(path.get_Chars(path.get_Length() - 1))) { path = path.Substring(0, path.get_Length() - 1); } int num = path.get_Length(); string text = path; List <string> list = new List <string>(); StorageFolder storageFolder = null; while (storageFolder == null && num != -1) { text = text.Substring(0, num); num = StorageUtility.GetPathSeparatorIndex(text, false); try { storageFolder = StorageUtility.GetFolderFromPath(text); } catch (Exception var_4_5D) { if (num != -1) { list.Add(text.Substring(num + 1)); } storageFolder = null; } } if (storageFolder == null) { throw new Exception("No accesible folder found in path: " + path); } int count = list.Count; if (list.Count > 0) { for (int i = list.Count - 1; i >= 0; i--) { storageFolder = StorageUtility.CreateFolder(storageFolder, list[i]); } } return(storageFolder.get_Path()); }
private static async Task <bool> WriteBytesAsync(string path, byte[] buffer) { bool result; if (path == null) { result = false; } else { path = StorageUtility.ConvertPathSeparators(path); int num = path.LastIndexOf('\\'); StorageFile storageFile = StorageUtility.CreateFileAtPath(path.Substring(0, num), path.Substring(num + 1), 3); await FileIO.WriteBytesAsync(storageFile, buffer); result = true; } return(result); }
public unsafe static long $Invoke13(long instance, long *args) { return(GCHandledObjects.ObjectToGCHandle(StorageUtility.ConvertPathSeparators(Marshal.PtrToStringUni(*(IntPtr *)args)))); }
public static void FileCopy(string sourcePath, string destPath) { sourcePath = StorageUtility.ConvertPathSeparators(sourcePath); destPath = StorageUtility.ConvertPathSeparators(destPath); StorageUtility.FileCopy(sourcePath, destPath, false); }