Esempio n. 1
0
        public void Restore(string path)
        {
            Photo photo = new Photo(path);

            IntPtr afcClient;
            ulong fileHandle;
            if (AFC.openPhoto(photo, device.Photos.PhotoList[device.Photos.PhotoList.Count - 1].Path + photo.getName(),
                device, AFC.FileOpenMode.AFC_FOPEN_WRONLY, out afcClient, out fileHandle) != AFC.AFCError.AFC_E_SUCCESS
                || afcClient == IntPtr.Zero || fileHandle == 0)
            {
                return;
            }

            byte[] fileContent = File.ReadAllBytes(photo.getNameWithPath());
            uint bytesWritten;
            AFC.afc_file_write(afcClient, fileHandle, fileContent, Convert.ToUInt32(photo.Size), out bytesWritten);

            AFC.closePhoto(afcClient, fileHandle);
        }
Esempio n. 2
0
        public void Restore(string path)
        {
            Photo photo = new Photo(path);

            IntPtr afcClient;
            ulong  fileHandle;

            if (AFC.openPhoto(photo, device.Photos.PhotoList[device.Photos.PhotoList.Count - 1].Path + photo.getName(),
                              device, AFC.FileOpenMode.AFC_FOPEN_WRONLY, out afcClient, out fileHandle) != AFC.AFCError.AFC_E_SUCCESS ||
                afcClient == IntPtr.Zero || fileHandle == 0)
            {
                return;
            }

            byte[] fileContent = File.ReadAllBytes(photo.getNameWithPath());
            uint   bytesWritten;

            AFC.afc_file_write(afcClient, fileHandle, fileContent, Convert.ToUInt32(photo.Size), out bytesWritten);

            AFC.closePhoto(afcClient, fileHandle);
        }