首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么将本地文件下传至FTP 并且要求是只读文件

2012-10-18 
如何将本地文件上传至FTP 并且要求是只读文件C# codeFileStream input new FileStream(fileName,FileMod

如何将本地文件上传至FTP 并且要求是只读文件

C# code
FileStream input = new FileStream(fileName,FileMode.Open,FileAccess.Read);                        if ( resume && input.Length < offset )            {                // different file size                Debug.WriteLine("Overwriting " + fileName, "FtpClient");                offset = 0;            }            else if ( resume && input.Length == offset )            {                // file done                input.Close();                Debug.WriteLine("Skipping completed " + fileName + " - turn resume off to not detect.", "FtpClient");                return;            }            // dont create untill we know that we need it            cSocket = this.createDataSocket();            if ( offset > 0 )            {                this.sendCommand( "REST " + offset );                if ( this.resultCode != 350 )                {                    Debug.WriteLine("Resuming not supported", "FtpClient");                    offset = 0;                }            }            this.sendCommand( "STOR " + Path.GetFileName(fileName) );            if ( this.resultCode != 125 && this.resultCode != 150 ) throw new FtpException(result.Substring(4));//zonghw            if ( offset != 0 )            {                Debug.WriteLine("Resuming at offset " + offset, "FtpClient" );                input.Seek(offset,SeekOrigin.Begin);            }            Debug.WriteLine( "Uploading file " + fileName + " to " + remotePath, "FtpClient" );            while ((bytes = input.Read(buffer,0,buffer.Length)) > 0)            {                cSocket.Send(buffer, bytes, 0);            }               input.Close();            if (cSocket.Connected)            {                cSocket.Close();            }            this.readResponse();            if( this.resultCode != 226 && this.resultCode != 250 ) throw new FtpException(this.result.Substring(4));


我现在使用的是这个,用流读取文件,本地能够变成只读的,但是到了FTP文件夹里就不是了

[解决办法]
那是ftp文件夹的权限问题吧

热点排行