コード例 #1
0
        public FileSystemFTPInfo[] GetFileSystemInfos(string pattern, SearchOption topDirectoryOnly)
        {
            if (pattern != "*")
            {
                throw new ArgumentOutOfRangeException("pattern", "Cannot be anything but *");
            }
            if (topDirectoryOnly != SearchOption.TopDirectoryOnly)
            {
                throw new ArgumentOutOfRangeException("topDirectoryOnly", "Cannot be anything but topDirectoryOnly");
            }

            return(FtpCmdInstance.GetDirList(path).ToArray());
        }
コード例 #2
0
        public void Open(FileMode rawCreationDisposition)
        {
            // http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx
            bool createZeroLengthFile = false;

            switch (rawCreationDisposition)
            {
            case FileMode.CreateNew:
                createZeroLengthFile = true;
                break;

            case FileMode.Create:
            case FileMode.Truncate:
                if (Exists)
                {
                    Delete();
                }
                createZeroLengthFile = true;
                break;

            case FileMode.Open:
                break;

            case FileMode.OpenOrCreate:
                createZeroLengthFile = !Exists;
                break;

            case FileMode.Append:
                // TODO: remember to use the APPE command
                break;

            default:
                throw new ArgumentOutOfRangeException("rawCreationDisposition");
            }
            if (createZeroLengthFile)
            {
                Stream dummy = new MemoryStream(new byte[0], 0, 0, false);
                FtpCmdInstance.PutFile(dummy, path, false);
                // Now force an internal reset to the attribes to find the Size / Dates etc.
                attributes = 0;
            }
        }
コード例 #3
0
 public void Create()
 {
     FtpCmdInstance.MakeDirectory(path);
     attributes = 0;
 }
コード例 #4
0
 /// <summary>
 /// Deletes a file or directory.
 /// </summary>
 /// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive. </exception><filterpriority>2</filterpriority>
 public override void Delete()
 {
     FtpCmdInstance.DeleteDirectory(path);
 }
コード例 #5
0
 /// <summary>
 /// Deletes a file or directory.
 /// </summary>
 /// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive. </exception><filterpriority>2</filterpriority>
 public override void Delete()
 {
     FtpCmdInstance.DeleteFile(path);
 }