当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.Write方法代码示例

本文整理汇总了C#中System.IO.FileInfo.Write方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.Write方法的具体用法?C# FileInfo.Write怎么用?C# FileInfo.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了FileInfo.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DownloadFromFtp

        public static bool DownloadFromFtp(string fileName)
        {
            bool ret = true;
            var dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path = Path.Combine(dirName, fileName);
            try
            {

                var wc = new WebClient { Credentials = new NetworkCredential("solidk", "KSolid") };
                var fileStream = new FileInfo(path).Create();
                //string downloadPath = Path.Combine("ftp://194.84.146.5/ForDealers",fileName);
                string downloadPath = Path.Combine(Furniture.Helpers.FtpAccess.resultFtp+"ForDealers", fileName);
                var str = wc.OpenRead(downloadPath);

                const int bufferSize = 1024;
                var buffer = new byte[bufferSize];
                int readCount = str.Read(buffer, 0, bufferSize);
                while (readCount > 0)
                {
                    fileStream.Write(buffer, 0, readCount);
                    readCount = str.Read(buffer, 0, bufferSize);
                }
                str.Close();
                fileStream.Close();
                wc.Dispose();
            }
            catch
            {
                ret = false;
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:32,代码来源:UpdaterFromFtp.cs

示例2: Find

        public IList<ISubtitleResult> Find(ISubtitleRequest request)
        {
            var url = _urlBuilder.BuildUrl(request.MovieName);
            var resultPage = _webpageDownloader.Download(url);

            var possibleResults = _resultExtractor.ExtractResultUrl(resultPage);

            // At the moment, if we don't have exactly one result, we give up (we'll improve that later)
            if (possibleResults.Count != 1)
                return new List<ISubtitleResult>();

            var secondResultPageUrl = "http://www.addic7ed.com/" + possibleResults[0];
            var secondResultPage = _webpageDownloader.Download(secondResultPageUrl);

            var results = _resultExtractor.ExtractSubtitleRecords(secondResultPage);

            foreach (var addictedSubtitle in results)
            {
                WebClient client = new WebClient();
                client.Headers.Add("Referer", secondResultPageUrl);

                var subtitle = client.DownloadString("http://www.addic7ed.com" + addictedSubtitle.DownloadLink);
                //var subtitle = _webpageDownloader.Download();

                using (var writer = new FileInfo(string.Format("c:\\out\\{0}.{1}.srt", request.MovieName, addictedSubtitle.Language)).CreateText())
                {
                    writer.Write(subtitle);
                }
            }

            return new List<ISubtitleResult>();
        }
开发者ID:antoinejaussoin,项目名称:subdown,代码行数:32,代码来源:IAddic7edSource.cs

示例3: Create

		public static void Create ( string fullPath, string data )
		{
			MakeDirectory (fullPath);

			using (FileStream fs = new FileInfo(fullPath).Open(FileMode.Create, FileAccess.ReadWrite)) 
			{

				byte[] byteData = System.Text.Encoding.ASCII.GetBytes(data);

				fs.Write(byteData, 0, byteData.Length);

			}
		}
开发者ID:SNY-GROUP,项目名称:EMProject,代码行数:13,代码来源:ComSystemIO.cs

示例4: Save

 /// <summary>
 /// Saves this instance.
 /// </summary>
 public void Save()
 {
     Plugins.ForEach(x => x.Save());
     string FileLocation = HttpContext.Current != null ? HttpContext.Current.Server.MapPath("~/App_Data/PluginList.txt") : AppDomain.CurrentDomain.BaseDirectory + "/App_Data/PluginList.txt";
     string DirectoryLocation = HttpContext.Current != null ? HttpContext.Current.Server.MapPath("~/App_Data/") : AppDomain.CurrentDomain.BaseDirectory + "/App_Data/";
     new System.IO.DirectoryInfo(DirectoryLocation).Create();
     using (FileStream Writer = new System.IO.FileInfo(FileLocation).Open(FileMode.Create, FileAccess.Write))
     {
         byte[] Content = Serialize(this).ToByteArray();
         Writer.Write(Content, 0, Content.Length);
     }
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:15,代码来源:PluginList.cs

示例5: WriteTemporalSkindleExecutable

        /// <summary>
        /// Creates a temporal executable of Skindle from the embedded resource
        /// </summary>
        /// <param name="skindleEXEStream">Skindle's stream</param>
        private void WriteTemporalSkindleExecutable(Stream skindleEXEStream)
        {
            var outputStream = new FileInfo(_skindlePath).OpenWrite();

            // read from embedded resource and write to output file
            const int size = 4096;
            byte[] bytes = new byte[4096];
            int numBytes;
            while ((numBytes = skindleEXEStream.Read(bytes, 0, size)) > 0)
            {
                outputStream.Write(bytes, 0, numBytes);
            }
            outputStream.Close();
            skindleEXEStream.Close();
        }
开发者ID:carballude,项目名称:SkindleGUI,代码行数:19,代码来源:frmMain.cs

示例6: cmdSave_Click

 private void cmdSave_Click(object sender, EventArgs e)
 {
     StreamWriter sw = new FileInfo(_installPath+"\\"+cboFile.Text).CreateText();
     sw.Write(txtLST.Text);
     sw.Close();
 }
开发者ID:JeremyAnsel,项目名称:YOGEME,代码行数:6,代码来源:LstForm.cs

示例7: saveMsgtolocal

 private void saveMsgtolocal()
 {
     FileStream stream = new FileInfo(this.sMsgFile).Open(FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
     string s = DateTime.Now.ToString() + " " + base.txtCarNo.Text.Trim() + " : " + this.txtMsgValue.Text.Trim() + "\r\n";
     byte[] bytes = Encoding.Default.GetBytes(s);
     stream.Write(bytes, 0, bytes.Length);
     stream.Flush();
     stream.Close();
 }
开发者ID:lexzh,项目名称:Myproject,代码行数:9,代码来源:itmSendTextMess.cs

示例8: createWebConfig

        /* Metodo que se encarga de la creacion del Web.Config */
        private bool createWebConfig()
        {
            try
            {
                /* Variable para almacenar el nombre del archivo de configuracion */
                string fileNameConfig = String.Empty;

                /* Verifica si un archivo existe en el proyecyo y con que nombre aparece */
                if(startupProject.IsFileInProject(projectPath + Path.DirectorySeparatorChar + "web.config"))
                    fileNameConfig = "web.config";
                else if(startupProject.IsFileInProject(projectPath + Path.DirectorySeparatorChar + "Web.config"))
                    fileNameConfig = "Web.config";
                /* El archivo no existe y por lo tanto lo creamos */
                else
                {
                    fileNameConfig = "web.config";
                    MonoDevelop.Projects.Text.TextFile.WriteFile(projectPath + Path.DirectorySeparatorChar + fileNameConfig, "", "UTF-8", true);
                    startupProject.AddFile(projectPath + Path.DirectorySeparatorChar + fileNameConfig);

                    FileInfo fiTemplate = new FileInfo(myNode.Addin.GetFilePath("web.config.template"));
                    byte [] arrayByte = new byte[fiTemplate.Length];

                    FileStream fsTemplate = fiTemplate.OpenRead();
                    FileStream fsWebConfig = new FileInfo(projectPath + Path.DirectorySeparatorChar + fileNameConfig).OpenWrite();

                    int byteLeidos = fsTemplate.Read(arrayByte, 0, arrayByte.Length);
                    fsWebConfig.Write(arrayByte, 0, byteLeidos);

                    fsTemplate.Close();
                    fsWebConfig.Close();

                    startupProject.Save(null);
                }

                webConfigPath = projectPath + Path.DirectorySeparatorChar + fileNameConfig;
                return true;
            }
            catch(Exception ex)
            {
                MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Error: " + ex.Message);
               	md.Run();
               	md.Destroy();
                return false;
            }
        }
开发者ID:denisjev,项目名称:SubscriptionService,代码行数:46,代码来源:ConnectionHandler.cs

示例9: ConvertPOM

        static unsafe void ConvertPOM( FileInfo _Source, FileInfo _Target, bool _sRGB, bool _GenerateMipMaps )
        {
            int	Width, Height;
            int	MipLevelsCount = 1;
            byte[][]	RAWImages = null;
            using ( Bitmap B = Image.FromFile( _Source.FullName ) as Bitmap )
            {
                if ( _GenerateMipMaps )
                {
                    double	Mips = Math.Log( 1+Math.Max( B.Width, B.Height ) ) / Math.Log( 2.0 );
                    MipLevelsCount = (int) Math.Ceiling( Mips );
                }

                RAWImages = new byte[MipLevelsCount][];

                Width = B.Width;
                Height = B.Height;

                // Build mip #0
                byte[]	RAWImage = new byte[4*Width*Height];
                RAWImages[0] = RAWImage;

                BitmapData	LockedBitmap = B.LockBits( new Rectangle( 0, 0, Width, Height ), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb );

                int			ByteIndex = 0;
                for ( int Y=0; Y < Height; Y++ )
                {
                    byte*	pScanline = (byte*) LockedBitmap.Scan0.ToPointer() + Y * LockedBitmap.Stride;
                    for ( int X=0; X < Width; X++ )
                    {
                        RAWImage[ByteIndex+2] = *pScanline++;
                        RAWImage[ByteIndex+1] = *pScanline++;
                        RAWImage[ByteIndex+0] = *pScanline++;
                        RAWImage[ByteIndex+3] = *pScanline++;
                        ByteIndex += 4;
                    }
                }

                B.UnlockBits( LockedBitmap );
            }

            // Generate other mips
            int	W = Width;
            int	H = Height;

            for ( int MipLevelIndex=1; MipLevelIndex < MipLevelsCount; MipLevelIndex++ )
            {
                int	PW = W;
                int	PH = W;
                W = Math.Max( 1, W >> 1 );
                H = Math.Max( 1, H >> 1 );

                byte[]	PreviousMip = RAWImages[MipLevelIndex-1];
                byte[]	CurrentMip = new byte[4*W*H];
                RAWImages[MipLevelIndex] = CurrentMip;

                byte	R, G, B, A;
                for ( int Y=0; Y < H; Y++ )
                {
                    int	PY0 = PH * Y / H;
                    int	PY1 = Math.Min( PY0+1, PH-1 );
                    for ( int X=0; X < W; X++ )
                    {
                        int	PX0 = PW * X / W;
                        int	PX1 = Math.Min( PX0+1, PW-1 );

                        if ( _sRGB )
                        {
                            R = Lin2sRGB( 0.25f * (sRGB2Lin( PreviousMip[4*(PW*PY0+PX0)+0] ) + sRGB2Lin( PreviousMip[4*(PW*PY0+PX1)+0] ) + sRGB2Lin( PreviousMip[4*(PW*PY1+PX0)+0] ) + sRGB2Lin( PreviousMip[4*(PW*PY1+PX1)+0]) ) );
                            G = Lin2sRGB( 0.25f * (sRGB2Lin( PreviousMip[4*(PW*PY0+PX0)+1] ) + sRGB2Lin( PreviousMip[4*(PW*PY0+PX1)+1] ) + sRGB2Lin( PreviousMip[4*(PW*PY1+PX0)+1] ) + sRGB2Lin( PreviousMip[4*(PW*PY1+PX1)+1]) ) );
                            B = Lin2sRGB( 0.25f * (sRGB2Lin( PreviousMip[4*(PW*PY0+PX0)+2] ) + sRGB2Lin( PreviousMip[4*(PW*PY0+PX1)+2] ) + sRGB2Lin( PreviousMip[4*(PW*PY1+PX0)+2] ) + sRGB2Lin( PreviousMip[4*(PW*PY1+PX1)+2]) ) );
                        }
                        else
                        {	// Simple average will do. I should handle normal maps mip-mapping more seriously but I just don't care...
                            R = (byte) ((PreviousMip[4*(PW*PY0+PX0)+0] + PreviousMip[4*(PW*PY0+PX1)+0] + PreviousMip[4*(PW*PY1+PX0)+0] + PreviousMip[4*(PW*PY1+PX1)+0]) >> 2);
                            G = (byte) ((PreviousMip[4*(PW*PY0+PX0)+1] + PreviousMip[4*(PW*PY0+PX1)+1] + PreviousMip[4*(PW*PY1+PX0)+1] + PreviousMip[4*(PW*PY1+PX1)+1]) >> 2);
                            B = (byte) ((PreviousMip[4*(PW*PY0+PX0)+2] + PreviousMip[4*(PW*PY0+PX1)+2] + PreviousMip[4*(PW*PY1+PX0)+2] + PreviousMip[4*(PW*PY1+PX1)+2]) >> 2);
                        }

                        A = (byte) ((PreviousMip[4*(PW*PY0+PX0)+3] + PreviousMip[4*(PW*PY0+PX1)+3] + PreviousMip[4*(PW*PY1+PX0)+3] + PreviousMip[4*(PW*PY1+PX1)+3]) >> 2);

                        CurrentMip[4*(W*Y+X)+0] = R;
                        CurrentMip[4*(W*Y+X)+1] = G;
                        CurrentMip[4*(W*Y+X)+2] = B;
                        CurrentMip[4*(W*Y+X)+3] = A;
                    }
                }
            }

            // Write the file
            using ( FileStream S = new FileInfo( _Target.FullName ).Create() )
                using ( BinaryWriter BW = new BinaryWriter( S ) )
                {
                    // Write type & format
                    BW.Write( (byte) 0 );	// 2D
                    BW.Write( (byte) (28 + (_sRGB ? 1 : 0)) );		// DXGI_FORMAT_R8G8B8A8_UNORM=28, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29

                    // Write dimensions
                    BW.Write( (Int32) Width );
                    BW.Write( (Int32) Height );
//.........这里部分代码省略.........
开发者ID:Patapom,项目名称:GodComplex,代码行数:101,代码来源:Program.cs

示例10: SaveScript

 public bool SaveScript()
 {
     if (CurrentScript != null) {
         CurrentScript.Write(scriptBox1.Editor.Document.Text);
     }
     else {
         saveFileDialog1.FileName = string.Empty;
         saveFileDialog1.InitialDirectory = Path.Combine(Application.StartupPath, "MyScripts");
         saveFileDialog1.ShowDialog();
         if (saveFileDialog1.FileName != string.Empty) {
             CurrentScript = new FileInfo(saveFileDialog1.FileName);
             CurrentScript.Write(scriptBox1.Editor.Document.Text);
         }
         else { SetStatusText("Save operation canceled by user!"); return false; }
     }
     this.Text = string.Concat("CaveBot - ", CurrentScript.Name);
     btnSave.Enabled = false;
     SetStatusText("Script saved!");
     scriptBox1.Editor.Document.SaveRevisionMark();
     scriptBox1.Editor.Update();
     return true;
 }
开发者ID:alexisjojo,项目名称:ktibiax,代码行数:22,代码来源:frm_Editor.cs

示例11: Downloading

        private void Downloading(WebClient wc, string neededLibrary, long sz)
        {
            if (!Directory.Exists(_mainDir.Root + "MrDoors_Solid_Update"))
                Directory.CreateDirectory(_mainDir.Root + "MrDoors_Solid_Update");
            string fullDownloadingPath = _mainDir.Root + "MrDoors_Solid_Update\\" + neededLibrary;
            if (File.Exists(fullDownloadingPath))
            {
                if (new FileInfo(fullDownloadingPath).Length == sz)
                    return;
            }

            var fileStream = new FileInfo(fullDownloadingPath).Create();

            label3.Visible = true;
            DateTime dt1 = DateTime.Now;
            var str = wc.OpenRead(Properties.Settings.Default.FtpPath + "/" + neededLibrary);

            const int bufferSize = 1024;
            var z = (int)(sz / bufferSize);
            var buffer = new byte[bufferSize];
            int readCount = str.Read(buffer, 0, bufferSize);
            progressBar1.Minimum = 1;
            progressBar1.Value = 1;
            progressBar1.Maximum = z;
            int i = 0;
            int countBytePerSec = 0;
            long commonByte = 0;

            while (readCount > 0)
            {
                DateTime dt2 = DateTime.Now;
                fileStream.Write(buffer, 0, readCount);
                commonByte += readCount;
                countBytePerSec += readCount;
                readCount = str.Read(buffer, 0, bufferSize);
                var dt = dt2 - dt1;
                if (dt.TotalSeconds > i)
                {
                    long lasttime = ((sz - commonByte) / countBytePerSec) * 10000000;
                    var f = new TimeSpan(lasttime);
                    string time;
                    if (f.Hours > 0)
                    {
                        if (f.Hours == 1)
                        {
                            time = f.Hours + " час " + f.Minutes + " минуты " + f.Seconds + " секунд";
                        }
                        else
                        {
                            if (f.Hours > 1 && f.Hours < 5)
                                time = f.Hours + " часа " + f.Minutes + " минуты " + f.Seconds + " секунд";
                            else
                                time = f.Hours + " часов " + f.Minutes + " минуты " + f.Seconds + " секунд";
                        }
                    }
                    else
                        if (f.Minutes > 0)
                            time = f.Minutes + " минут " + f.Seconds + " секунд";
                        else
                            time = f.Seconds + " секунд";
                    countBytePerSec = countBytePerSec / 1024;
                    if (((countBytePerSec) / 1024) > 1)
                    {
                        countBytePerSec = countBytePerSec / 1024;
                        label3.Text = dt.Minutes + @":" + dt.Seconds + @" секунд   Скорость: " + countBytePerSec +
                                      @" Мб/с   Осталось приблизительно: " + time;
                    }
                    else
                        label3.Text = dt.Minutes + @":" + dt.Seconds + @" секунд   Скорость: " + countBytePerSec + @" Кб/с   Осталось приблизительно: " + time;
                    Application.DoEvents();
                    countBytePerSec = 0;
                    i++;
                }
                progressBar1.Increment(1);
            }
            str.Close();
            fileStream.Close();
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:78,代码来源:UpdatingLib.cs

示例12: SetValue

        /// <summary>
        /// Sets a value in the specified key of the specified section within the ini file's contents.
        /// </summary>
        /// <param name="section">Ini file section</param>
        /// <param name="key">Ini file section key</param>
        /// <param name="value">Key value to assign</param>
        /// <returns>True if value assignment has been successful otherwise false.</returns>
        public bool SetValue(string section, string key, string value)
        {
            bool _set = false;
            if (String.IsNullOrEmpty(_filecontents.RLTrim())) _filecontents = Contents();

            if (!String.IsNullOrEmpty(_filecontents.RLTrim()))
            {
                string[] _lines = _filecontents.Split("\n".ToCharArray());
                int _startline = 0; int _endline = 0;

                for (int i = 0; i <= (_lines.Length - 1); i++)
                {
                    string _line = _lines[i];
                    if (_line.RLTrim().ToUpper() == "[" + section.ToUpper() + "]")
                    {
                        _startline = i; break;
                    }
                }

                if ((_startline + 1) <= (_lines.Length - 1))
                {

                    for (int i = (_startline + 1); i <= (_lines.Length - 1); i++)
                    {
                        string _line = _lines[i];
                        if (_line.RLTrim().StartsWith("[") &&
                            _line.RLTrim().EndsWith("]")) break;
                        _endline = i;
                    }

                    for (int i = _startline; i <= _endline; i++)
                    {
                        string _line = _lines[i];
                        char[] _chars = _line.ToCharArray();
                        string _key = "";

                        foreach (char _char in _chars)
                        {
                            if (_char.ToString() != " ") _key += _char.ToString();
                            if (_key.RLTrim().ToUpper().Contains(key.ToUpper() + "="))
                            {
                                _lines[i] = key.ToUpper() + "=" + value;
                                StreamWriter _writer = new StreamWriter(_filename);
                                try
                                {
                                    for (int a = 0; a <= (_lines.Length - 1); a++)
                                    { _writer.WriteLine(_lines[a]); }
                                    _set = true;
                                }
                                catch { _set = false; }
                                finally
                                { _writer.Close(); _writer.Dispose(); Materia.RefreshAndManageCurrentProcess(); }

                                return _set;
                            }
                        }

                        StringBuilder _contents = new StringBuilder();
                        _contents.Append(_filecontents);

                        if (_endline < (_lines.Length - 1)) _filecontents.RLTrim().Replace(_lines[_endline], _lines[_endline] + "\n" + key + "=" + value);
                        else _filecontents += (_filecontents.RLTrim().EndsWith("\n") ? "" : "\n") + key + "=" + value;

                        FileInfo _file = new FileInfo(_filename);
                        _set = _file.Write(_filecontents);
                    }
                }
            }

            return _set;
        }
开发者ID:lead-programmer2,项目名称:Development.Materia,代码行数:78,代码来源:IniFile.cs

示例13: DownloadDll

        private bool DownloadDll(Stream stream, FtpWebRequest reqFtp, string newVersion, string newName, out string newFileLocation)
        {
            if (Directory.Exists(Furniture.Helpers.LocalAccounts.modelPathResult.Replace("_SWLIB_", "_SWLIB_BACKUP")))
            {
                string warnMessage =
                    @"�������� ���� �������� ! � ������ ������ ��� �������������� ������� ������� ��������� ������, ��������� ������� � ��������� ����������� ������ ����� ���� ��� ! � ������ ������� �������������� ������� (���� ����\��������)�������� ����������� ������ � �� ����������� ���������,���������� � ��������� ������������ ������� �� ������������ � ��������� ������������ ������� ����������.";
                MessageBox.Show(warnMessage, "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            stream.Close();
            reqFtp.Abort();
            //long size = GetSizeForFurnitureDll(Properties.Settings.Default.FurnFtpPath + newVersion);
            long size = GetSizeForFurnitureDll(Furniture.Helpers.FtpAccess.resultFtp + newVersion);
            UserProgressBar pb;
            SwApp.GetUserProgressBar(out pb);
            FileStream fileStream = null;
            try
            {
                fileStream = new FileInfo(newName).Create();
            }
            catch (Exception)
            {
                MessageBox.Show("�� �������� ������� ���� " + newName + "�������� ��-�� ���� ��� ��� ��� ���� ����� �������.");
            }

            var wc = new WebClient { Credentials = new NetworkCredential(Properties.Settings.Default.FurnFtpName, Properties.Settings.Default.FurnFtpPass) };
            var str =
                //wc.OpenRead(Properties.Settings.Default.FurnFtpPath + newVersion + "/Furniture.dll");
                wc.OpenRead(Furniture.Helpers.FtpAccess.resultFtp + newVersion + "/Furniture.dll");
            const int bufferSize = 1024;
            var z = (int)(size / bufferSize);
            var buffer = new byte[bufferSize];
            int readCount = str.Read(buffer, 0, bufferSize);
            pb.Start(0, z, "���������� ���������");
            int i = 0;
            while (readCount > 0)
            {
                fileStream.Write(buffer, 0, readCount);
                readCount = str.Read(buffer, 0, bufferSize);
                pb.UpdateProgress(i);
                i++;
            }
            pb.End();
            fileStream.Close();
            wc.Dispose();
            newFileLocation = newName;
            return true;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:47,代码来源:SwAddin.cs

示例14: DownloadUpdFrn

        private static bool DownloadUpdFrn(out string path)
        {
            bool ret = true;
            path = "";
            try
            {
                path = Directory.Exists(@"D:\") ? @"D:\download_update_furniture.exe" : @"C:\download_update_furniture.exe";
                string pathUpd = Directory.Exists(@"D:\") ? @"D:\update_furniture.exe" : @"C:\update_furniture.exe";
                if (File.Exists(path) && File.Exists(pathUpd))
                    return true;
                var wc = new WebClient { Credentials = new NetworkCredential("solidk", "KSolid") };
                var fileStream = new FileInfo(path).Create();

                //var str = wc.OpenRead("ftp://194.84.146.5/download_update_furniture.exe");
                var str = wc.OpenRead(Furniture.Helpers.FtpAccess.resultFtp + "download_update_furniture.exe");

                const int bufferSize = 1024;
                var buffer = new byte[bufferSize];
                int readCount = str.Read(buffer, 0, bufferSize);
                while (readCount > 0)
                {
                    fileStream.Write(buffer, 0, readCount);
                    readCount = str.Read(buffer, 0, bufferSize);
                }
                str.Close();
                fileStream.Close();
                fileStream = new FileInfo(pathUpd).Create();
                //str = wc.OpenRead("ftp://194.84.146.5/update_furniture.exe");
                str = wc.OpenRead(Furniture.Helpers.FtpAccess.resultFtp + "update_furniture.exe");

                readCount = str.Read(buffer, 0, bufferSize);
                while (readCount > 0)
                {
                    fileStream.Write(buffer, 0, readCount);
                    readCount = str.Read(buffer, 0, bufferSize);
                }
                str.Close();
                fileStream.Close();
                wc.Dispose();
            }
            catch
            {
                ret = false;
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:46,代码来源:SwAddin.cs

示例15: SaveScript

 public void SaveScript()
 {
     if (CurrentScript != null) {
         CurrentScript.Write(scriptBox1.Editor.Document.Text);
     }
     else {
         saveFileDialog1.FileName = string.Empty;
         saveFileDialog1.ShowDialog();
         if (saveFileDialog1.FileName != string.Empty) {
             CurrentScript = new FileInfo(saveFileDialog1.FileName);
             CurrentScript.Write(scriptBox1.Editor.Document.Text);
         }
         else { return; }
     }
     this.Text = CurrentScript.Name;
     btnSave.Enabled = false;
     SetStatusText("Script saved!");
     scriptBox1.Editor.Document.SaveRevisionMark();
     scriptBox1.Editor.Update();
 }
开发者ID:alexisjojo,项目名称:ktibiax,代码行数:20,代码来源:Copy+of+frm_Editor.cs


注:本文中的System.IO.FileInfo.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。