Beispiel #1
0
 void Upload()
 {
     try
     {
         ShowProgress(true);
         foreach (ListViewItem lvItem in lvDragItem)
         {
             if (nfsClient.FileExists(nfsClient.Combine(lvItem.Text, RemoteFolder)))
             {
                 if (MessageBox.Show("Do you want to overwrite " + lvItem.Text + "?", "NFSClient", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     nfsClient.DeleteFile(nfsClient.Combine(lvItem.Text, RemoteFolder));
                 }
                 else
                 {
                     continue;
                 }
             }
             CurrentItem = lvItem.Text;
             CurrentSize = long.Parse(lvItem.SubItems[1].Text);
             _lTotal     = 0;
             string SourceName = System.IO.Path.Combine(LocalFolder, CurrentItem);
             nfsClient.Write(nfsClient.Combine(CurrentItem, RemoteFolder), SourceName);
         }
         ShowProgress(false);
     }
     catch (ThreadAbortException)
     {
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "NFS Client");
         ShowProgress(false);
     }
 }
Beispiel #2
0
        public int CreateFile(string filename, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, DokanFileInfo info)
        {
            int ret = DokanNet.DOKAN_SUCCESS;

            filename = CleanFileName(filename);

            try
            {
                Debug("CreateFile {0}", filename);

                string Directory = nfsClient.GetDirectoryName(filename);
                string FileName  = nfsClient.GetFileName(filename);
                string FullPath  = nfsClient.Combine(FileName, Directory);

                if (nfsClient.IsDirectory(FullPath))
                {
                    return(ret);
                }

                switch (mode)
                {
                case FileMode.Open:
                {
                    Debug("Open");
                    if (!nfsClient.FileExists(FullPath))
                    {
                        ret = -DokanNet.ERROR_FILE_NOT_FOUND;
                    }
                    break;
                }

                case FileMode.CreateNew:
                {
                    Debug("CreateNew");
                    if (nfsClient.FileExists(FullPath))
                    {
                        ret = -DokanNet.ERROR_ALREADY_EXISTS;
                    }
                    else
                    {
                        nfsClient.CreateFile(FullPath);
                    }
                    break;
                }

                case FileMode.Create:
                {
                    Debug("Create");
                    if (nfsClient.FileExists(FullPath))
                    {
                        nfsClient.DeleteFile(FullPath);
                    }

                    nfsClient.CreateFile(FullPath);
                    break;
                }

                case FileMode.OpenOrCreate:
                {
                    Debug("OpenOrCreate");
                    if (!nfsClient.FileExists(FullPath))
                    {
                        nfsClient.CreateFile(FullPath);
                    }
                    break;
                }

                case FileMode.Truncate:
                {
                    Debug("Truncate");
                    if (!nfsClient.FileExists(FullPath))
                    {
                        ret = -DokanNet.ERROR_FILE_NOT_FOUND;
                    }
                    else
                    {
                        nfsClient.CreateFile(FullPath);
                    }
                    break;
                }

                case FileMode.Append:
                {
                    Debug("Appen");
                    if (!nfsClient.FileExists(FullPath))
                    {
                        ret = -DokanNet.ERROR_FILE_NOT_FOUND;
                    }
                    break;
                }

                default:
                {
                    Debug("Error unknown FileMode {0}", mode);
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                ret = -DokanNet.DOKAN_ERROR;
                Debug("CreateFile file {0} exception {1}", filename, ex.Message);
            }
            return(ret);
        }