Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
 public unsafe static long $Invoke17(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(StorageUtility.CreateFileAtPath(Marshal.PtrToStringUni(*(IntPtr *)args), Marshal.PtrToStringUni(*(IntPtr *)(args + 1)), *(int *)(args + 2))));
 }