CopyFile() public method

public CopyFile ( string sourceFileName, string destinationFileName ) : void
sourceFileName string
destinationFileName string
return void
Esempio n. 1
0
 public void CopyFile_RaisesInvalidPath()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         AssertExtensions.Throws <ArgumentException>("path", null, () => isf.CopyFile("\0bad", "bar"));
         AssertExtensions.Throws <ArgumentException>("path", null, () => isf.CopyFile("foo", "\0bad"));
     }
 }
Esempio n. 2
0
 public void CopyFile_RaisesIsolatedStorageException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         Assert.Throws <IsolatedStorageException>(() => isf.CopyFile("\0bad", "bar"));
         Assert.Throws <IsolatedStorageException>(() => isf.CopyFile("foo", "\0bad"));
     }
 }
Esempio n. 3
0
 public void CopyFile_ThrowsArgumentException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         AssertExtensions.Throws <ArgumentException>("sourceFileName", () => isf.CopyFile(string.Empty, "bar"));
         AssertExtensions.Throws <ArgumentException>("sourceFileName", () => isf.CopyFile(string.Empty, "bar", true));
         AssertExtensions.Throws <ArgumentException>("destinationFileName", () => isf.CopyFile("foo", string.Empty));
         AssertExtensions.Throws <ArgumentException>("destinationFileName", () => isf.CopyFile("foo", string.Empty, true));
     }
 }
Esempio n. 4
0
 public void CopyFile_ThrowsArgumentNull()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         Assert.Throws <ArgumentNullException>("sourceFileName", () => isf.CopyFile(null, "bar"));
         Assert.Throws <ArgumentNullException>("sourceFileName", () => isf.CopyFile(null, "bar", true));
         Assert.Throws <ArgumentNullException>("destinationFileName", () => isf.CopyFile("foo", null));
         Assert.Throws <ArgumentNullException>("destinationFileName", () => isf.CopyFile("foo", null, true));
     }
 }
Esempio n. 5
0
 public void CopyFile_DoesNotExist()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         Assert.Throws <FileNotFoundException>(() => isf.CopyFile("CopyFile_DoesNotExist", "CopyFile_DoesNotExist_Copy"));
     }
 }
Esempio n. 6
0
        private void showImage()
        {
            if (App.ViewModel.forShare != null)
            {
                imagePicker.Content = App.ViewModel.forShare.ItemName;
                imagePicker.Opacity = 0.5;
                System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                //点击超链接后图片存在
                if (isf.FileExists(App.ViewModel.forShare.ItemName + ".jpg"))
                {
                    isf.CopyFile(App.ViewModel.forShare.ItemName + ".jpg", "abc.jpg", true);
                    System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.OpenFile("abc.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    System.Windows.Media.Imaging.BitmapImage            bmp1        = new System.Windows.Media.Imaging.BitmapImage();
                    bmp1.SetSource(PhotoStream); //把文件流转换为图片
                    PhotoStream.Close();         //读取完毕,关闭文件流

                    System.Windows.Media.ImageBrush ib = new System.Windows.Media.ImageBrush();
                    ib.ImageSource = bmp1;
                    tip.Background = ib;      //把图片设置为控件的背景图
                    //imageTip.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
            //如果存在背景,则显示关联按钮
            if (tip.Background != null)
            {
                appBar3();
            }
        }
Esempio n. 7
0
 public void CopyClosedFile_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Close();
         Assert.Throws <InvalidOperationException>(() => isf.CopyFile("foo", "bar"));
     }
 }
Esempio n. 8
0
 public void CopyFile_ThrowsIsolatedStorageException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <IsolatedStorageException>(() => isf.CopyFile("foo", "bar"));
     }
 }
Esempio n. 9
0
 private void Picture_Save(object sender, EventArgs e)
 {
     System.IO.IsolatedStorage.IsolatedStorageFile isf2 = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
     //  if (isf2.FileExists(imagePicker.Content + ".jpg")) isf2.DeleteFile(imagePicker.Content + ".jpg");
     if (isf2.FileExists("abc.jpg"))
     {
         isf2.CopyFile("abc.jpg", imagePicker.Content + ".jpg", true);
         //MessageBox.Show("关联成功");
         //takePhote();
         if (MessageBox.Show(txtnote.Resources.StringLibrary.chenggong + "!", txtnote.Resources.StringLibrary.guanlian, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
         {
             MainPano.DefaultItem = ViewPano;
             imageTip.Visibility  = System.Windows.Visibility.Visible;
         }
     }
     else
     {
         MessageBox.Show("Fail!");
     }
 }
Esempio n. 10
0
        public void CopyDirectory(string sourcePath, string destinationPath, IsolatedStorageFile iso)
        {
            if (!iso.DirectoryExists(sourcePath))
            return;

              var folders = iso.GetDirectoryNames(sourcePath + "/" + "*.*");

              foreach (var folder in folders)
              {
            string sourceFolderPath = sourcePath + "/" + folder;
            string destinationFolderPath = destinationPath + "/" + folder;

            iso.CreateDirectory(destinationFolderPath);
            CopyDirectory(sourceFolderPath, destinationFolderPath, iso);
              }

              foreach (var file in iso.GetFileNames(sourcePath + "/" + "*.*"))
              {
            string sourceFilePath = sourcePath + "/" + file;
            string destinationFilePath = destinationPath + "/" + file;

            iso.CopyFile(sourceFilePath, destinationFilePath);
              }
        }
Esempio n. 11
0
        private void CopyDirectory(string sourceDir, string destDir, IsolatedStorageFile isoFile)
        {
            string path = File.AddSlashToDirectory(sourceDir);

            bool bExists = isoFile.DirectoryExists(destDir);

            if (!bExists)
            {
                isoFile.CreateDirectory(destDir);
            }

            destDir = File.AddSlashToDirectory(destDir);

            string[] files = isoFile.GetFileNames(path + "*");

            if (files.Length > 0)
            {
                foreach (string file in files)
                {
                    isoFile.CopyFile(path + file, destDir + file, true);
                }
            }
            string[] dirs = isoFile.GetDirectoryNames(path + "*");
            if (dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    CopyDirectory(path + dir, destDir + dir, isoFile);
                }
            }
        }
	    private void CacheForMerge(IsolatedStorageFile appStorage)
	    {
            if (appStorage.FileExists("MergeCache"))
            {
                appStorage.DeleteFile("MergeCache");
            }

            appStorage.CopyFile(GetFileName(), "MergeCache");
	    }
Esempio n. 13
0
        private static void CopyDirectory(string sourceDir, string destDir, IsolatedStorageFile isoFile)
        {
            string path;
            if (sourceDir.EndsWith("\\"))
            {
                path = sourceDir;
            }
            else
            {
                path = sourceDir + "\\";
            }

            bool bExists = isoFile.DirectoryExists(destDir);
            if (!bExists)
            {
                isoFile.CreateDirectory(destDir);
            }
            if (!destDir.EndsWith("\\"))
            {
                destDir += "\\";
            }

            string[] files = isoFile.GetFileNames(path + "*");

            if (files.Length > 0)
            {
                foreach (string file in files)
                {
                    isoFile.CopyFile(path + file, destDir + file, true);
                }
            }
            string[] dirs = isoFile.GetDirectoryNames(path + "*");
            if (dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    CopyDirectory(path + dir, destDir + dir, isoFile);
                }
            }
        }