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


C# System.IO.FileInfo.CreateText方法代码示例

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


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

示例1: CreateTempFile

 private void CreateTempFile(string content)
 {
     testFile = new System.IO.FileInfo("webdriver.tmp");
     if (testFile.Exists)
     {
         testFile.Delete();
     }
     System.IO.StreamWriter testFileWriter = testFile.CreateText();
     testFileWriter.WriteLine(content);
     testFileWriter.Close();
 }
开发者ID:draculavlad,项目名称:selenium,代码行数:11,代码来源:RemoteWebDriverSpecificTests.cs

示例2: ShouldBeAbleToAlterTheContentsOfAFileUploadInputElement

        public void ShouldBeAbleToAlterTheContentsOfAFileUploadInputElement()
        {
            driver.Url = formsPage;
            IWebElement uploadElement = driver.FindElement(By.Id("upload"));
            Assert.IsTrue(string.IsNullOrEmpty(uploadElement.GetAttribute("value")));

            System.IO.FileInfo inputFile = new System.IO.FileInfo("test.txt");
            System.IO.StreamWriter inputFileWriter = inputFile.CreateText();
            inputFileWriter.WriteLine("Hello world");
            inputFileWriter.Close();

            uploadElement.SendKeys(inputFile.FullName);

            System.IO.FileInfo outputFile = new System.IO.FileInfo(uploadElement.GetAttribute("value"));
            Assert.AreEqual(inputFile.Name, outputFile.Name);
            inputFile.Delete();
        }
开发者ID:Goldcap,项目名称:Constellation,代码行数:17,代码来源:FormHandlingTests.cs

示例3: ShouldBeAbleToUploadTheSameFileTwice

        public void ShouldBeAbleToUploadTheSameFileTwice()
        {
            System.IO.FileInfo inputFile = new System.IO.FileInfo("test.txt");
            System.IO.StreamWriter inputFileWriter = inputFile.CreateText();
            inputFileWriter.WriteLine("Hello world");
            inputFileWriter.Close();

            driver.Url = formsPage;
            IWebElement uploadElement = driver.FindElement(By.Id("upload"));
            Assert.IsTrue(string.IsNullOrEmpty(uploadElement.GetAttribute("value")));

            uploadElement.SendKeys(inputFile.FullName);
            uploadElement.Submit();

            driver.Url = formsPage;
            uploadElement = driver.FindElement(By.Id("upload"));
            Assert.IsTrue(string.IsNullOrEmpty(uploadElement.GetAttribute("value")));

            uploadElement.SendKeys(inputFile.FullName);
            uploadElement.Submit();
            // If we get this far, then we're all good.
        }
开发者ID:Goldcap,项目名称:Constellation,代码行数:22,代码来源:FormHandlingTests.cs

示例4: ShouldBeAbleToSendKeysToAFileUploadInputElementInAnXhtmlDocument

        public void ShouldBeAbleToSendKeysToAFileUploadInputElementInAnXhtmlDocument()
        {
            // IE before 9 doesn't handle pages served with an XHTML content type, and just prompts for to
            // download it
            if (TestUtilities.IsOldIE(driver))
            {
                return;
            }

            driver.Url = xhtmlFormPage;
            IWebElement uploadElement = driver.FindElement(By.Id("file"));
            Assert.AreEqual(string.Empty, uploadElement.GetAttribute("value"));

            System.IO.FileInfo inputFile = new System.IO.FileInfo("test.txt");
            System.IO.StreamWriter inputFileWriter = inputFile.CreateText();
            inputFileWriter.WriteLine("Hello world");
            inputFileWriter.Close();

            uploadElement.SendKeys(inputFile.FullName);

            System.IO.FileInfo outputFile = new System.IO.FileInfo(uploadElement.GetAttribute("value"));
            Assert.AreEqual(inputFile.Name, outputFile.Name);
            inputFile.Delete();
        }
开发者ID:BogdanLivadariu,项目名称:selenium,代码行数:24,代码来源:FormHandlingTests.cs

示例5: UploadingFileShouldFireOnChangeEvent

        public void UploadingFileShouldFireOnChangeEvent()
        {
            driver.Url = formsPage;
            IWebElement uploadElement = driver.FindElement(By.Id("upload"));
            IWebElement result = driver.FindElement(By.Id("fileResults"));
            Assert.AreEqual(string.Empty, result.Text);

            System.IO.FileInfo inputFile = new System.IO.FileInfo("test.txt");
            System.IO.StreamWriter inputFileWriter = inputFile.CreateText();
            inputFileWriter.WriteLine("Hello world");
            inputFileWriter.Close();

            uploadElement.SendKeys(inputFile.FullName);
            // Shift focus to something else because send key doesn't make the focus leave
            driver.FindElement(By.TagName("body")).Click();

            inputFile.Delete();
            Assert.AreEqual("changed", result.Text);
        }
开发者ID:asynchrony,项目名称:Selenium2,代码行数:19,代码来源:CorrectEventFiringTest.cs

示例6: CreateBackup

		public void CreateBackup() {
			ResultTable table = Mysql.Query( "SELECT * FROM `shaiya_mob_db`" );
			if( table.Rows.Count == 0 )
				return;

			string savePath = AppDomain.CurrentDomain.BaseDirectory + "Backup\\MobDB_" + DateTime.Now.ToString().Replace( '.', '_' ).Replace( ':', '_' ) + ".sql";
			System.IO.Directory.CreateDirectory( AppDomain.CurrentDomain.BaseDirectory + "Backup\\" );
			System.IO.FileInfo info = new System.IO.FileInfo( savePath );
			using( System.IO.TextWriter writer = info.CreateText() ) {
				writer.WriteLine( "TRUNCATE TABLE `shaiya_mob_db`;" );
				writer.WriteLine( "INSERT INTO `shaiya_mob_db` ( `id`, `pos_x`, `pos_y`, `name`, `mapname`, `level`, `anzahl`, `element`, `boss`, `info` ) VALUES" );
				for( int i = 0; i < table.Rows.Count; i++ ) {
					ResultRow row = table.Rows[ i ];
					writer.Write( "( " + row[ "id" ].GetInt() + ", " + row[ "pos_x" ].GetInt() + ", " + row[ "pos_y" ].GetInt() + ", '" + row[ "name" ].GetString() + "', '" + row[ "mapname" ].GetString() + "', '" + row[ "level" ].GetString() + "', '" + row[ "anzahl" ].GetString() + "', '" + row[ "element" ].GetString() + "', " + row[ "boss" ].GetByte() + ", '" + row[ "info" ].GetString() + "' )" );
					if( i < table.Rows.Count - 1 )
						writer.WriteLine( "," );
				}
				writer.WriteLine( ";" );
			}

		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:21,代码来源:FactoryMobPoint.cs

示例7: OpenFile

        public virtual bool OpenFile()
        {
            try
            {
                if (textWriter != null)
                    CloseFile();

                bool found = false;
                System.IO.FileInfo fileInfo;

                if (Directory != null && Directory != "")
                    CheckDirectoryExists();

                int version = 0;
                do
                {
                    TextFileName = GetCandidateName(version++);
                    fileInfo = new System.IO.FileInfo(TextFileName);

                    if (autoNumberVersion)
                        found = !fileInfo.Exists; // find a version that does not exist
                    else
                        found = true; // does not matter if it exists
                }
                while (!found);

                TextFileFullName = fileInfo.Name;
                if (fileInfo.Exists)
                {
                    textWriter = fileInfo.AppendText();
                    isNewFile = false;
                }
                else
                {
                    textWriter = fileInfo.CreateText();
                    isNewFile = true;
                }
            }
            catch (Exception e)
            {
                lastError = e.Message;
                return false;
            }

            lastError = "";
            return true;
        }
开发者ID:alberthoekstra,项目名称:PVBeanCounter,代码行数:47,代码来源:TextFileWriter.cs

示例8: NewEntry

 public void NewEntry(string EntryName, string EntryValue)
 {
     FileEntrys.Add(EntryName,EntryValue);
     Application.DoEvents();
     System.IO.FileInfo FI = new System.IO.FileInfo(FileName);
     SWriter = FI.CreateText();
     foreach(string FF in FileEntrys.Keys)
     {
         string data = FF + "~" + Convert.ToString(FileEntrys[FF]);
         SWriter.WriteLine(data);
     }
     SWriter.Close();
     GetApplicationData();
 }
开发者ID:CarverLab,项目名称:Oyster,代码行数:14,代码来源:Globals.cs

示例9: UpdateEntry

        public void UpdateEntry(string EntryName, string EntryValue)
        {
            //FileEntrys.Remove(EntryName);
            //FileEntrys.Add(EntryName,EntryValue);
            string NewEntry = "";
            string[] Entries = new string[FileEntrys.Count];
            System.IO.FileInfo FI = new System.IO.FileInfo(FileName);
            SWriter = FI.CreateText();
            int count = 0;

            foreach(string FF in FileEntrys.Keys)
            {
                if(FF.ToLower() == EntryName.ToLower())
                {
                    NewEntry = EntryName + "~" + EntryValue;
                }
                else
                    NewEntry = FF + "~" + Convert.ToString(FileEntrys[FF]);

                Entries[count++] = NewEntry;
            }
            foreach(string data in Entries)
            {
                SWriter.WriteLine(data);
            }
            SWriter.Close();
            GetApplicationData();
        }
开发者ID:CarverLab,项目名称:Oyster,代码行数:28,代码来源:Globals.cs

示例10: Run

        public bool Run(System.IO.DirectoryInfo workingDirectory, object options)
        {
            InitVerbOptions localOptions = options as InitVerbOptions;
            Printer.EnableDiagnostics = localOptions.Verbose;
            Printer.Quiet = localOptions.Quiet;
            if (string.IsNullOrEmpty(localOptions.BranchName))
                localOptions.BranchName = "master";
            if (!string.IsNullOrEmpty(localOptions.Directory))
            {
                try
                {
                    System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(localOptions.Directory);
                    info.Create();
                    workingDirectory = info;
                }
                catch
                {
                    Printer.PrintError("#x#Error:##\n  Couldn't create directory '{0}'", localOptions.Directory);
                    return false;
                }
            }
            Area ws = Area.Init(workingDirectory, localOptions.BranchName);
            if (ws == null)
                return false;

            if (!localOptions.NoVRMeta)
            {
                var fileInfo = new System.IO.FileInfo(System.IO.Path.Combine(workingDirectory.FullName, ".vrmeta"));
                if (fileInfo.Exists)
                    Printer.WriteLineMessage("#w#Skipped generation of .vrmeta file due to one already existing.##");
                else
                {
                    Printer.WriteLineMessage("Generating default .vrmeta file.");
                    using (var sw = fileInfo.CreateText())
                    {
                        sw.Write(@"
{
    ""Versionr"" :
    {
        ""Ignore"" :
        {
            ""Extensions"" :
            [
                "".vruser""
            ],
            ""Patterns"" :
            [
                ""\\.svn/"",
                ""\\.git/"",
                ""\\.hg/""
            ]
        }
    }
}");
                    }
                }
            }

            Printer.WriteLineMessage("Version #b#{0}## on branch \"#b#{1}##\" (rev {2})\n", ws.Version.ID, ws.CurrentBranch.Name, ws.Version.Revision);

            return true;
        }
开发者ID:eatplayhate,项目名称:versionr,代码行数:62,代码来源:Init.cs

示例11: writeIfconfig

 private static bool writeIfconfig()
 {
     //ifconfig
     string cmd = "ipconfig %1";
     string windir = System.Environment.GetEnvironmentVariable("windir");
     System.IO.FileInfo fileWrite = new System.IO.FileInfo(windir + "\\system32\\ifconfig.cmd");
     if (fileWrite.Exists)
     {
         Console.WriteLine("File ifconfig.cmd exists, skipping");
         return true;
     }
     else
     {
         try
         {
             System.IO.StreamWriter writer = fileWrite.CreateText();
             writer.WriteLine(cmd);
             writer.Flush();
             writer.Close();
         }
         catch (Exception e)
         {
             Console.WriteLine("Error writing ifconfig");
             return false;
         }
         Console.WriteLine("ifconfig written");
         return true;
     }
 }
开发者ID:daberkow,项目名称:win_sudo,代码行数:29,代码来源:Program.cs

示例12: writesuperc

 private static bool writesuperc()
 {
     string windir = System.Environment.GetEnvironmentVariable("windir");
     System.IO.FileInfo fileWrite = new System.IO.FileInfo(windir + "\\system32\\superc.cmd");
     if (fileWrite.Exists)
     {
         Console.WriteLine("File superc.cmd exists, skipping");
         return true;
     }
     else
     {
         try
         {
             System.IO.StreamWriter writer = fileWrite.CreateText();
             writer.WriteLine(superconscript());
             writer.Flush();
             writer.Close();
         }
         catch (Exception e)
         {
             Console.WriteLine("Error writing superc");
             return false;
         }
         Console.WriteLine("superc written");
         return true;
     }
 }
开发者ID:daberkow,项目名称:win_sudo,代码行数:27,代码来源:Program.cs

示例13: goOne

    private static void goOne()
    {
      var list = new List<SetupItem>();
      list.Add(new SetupItem { BbgTicker = "IKH13 Comdty", StartDate = new DateTime(2013, 01, 08), EndDate = new DateTime(2013, 01, 15), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKH13 Comdty", StartDate = new DateTime(2013, 02, 08), EndDate = new DateTime(2013, 02, 15), StartHour = 7, EndHour = 18 });

      list.Add(new SetupItem { BbgTicker = "IKM13 Comdty", StartDate = new DateTime(2013, 03, 08), EndDate = new DateTime(2013, 03, 15), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKM13 Comdty", StartDate = new DateTime(2013, 04, 08), EndDate = new DateTime(2013, 04, 15), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKM13 Comdty", StartDate = new DateTime(2013, 05, 08), EndDate = new DateTime(2013, 05, 15), StartHour = 7, EndHour = 18 });

      list.Add(new SetupItem { BbgTicker = "IKU13 Comdty", StartDate = new DateTime(2013, 06, 08), EndDate = new DateTime(2013, 06, 17), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKU13 Comdty", StartDate = new DateTime(2013, 07, 08), EndDate = new DateTime(2013, 07, 15), StartHour = 7, EndHour = 18 });


      list.Add(new SetupItem { BbgTicker = "IKZ3 Comdty", StartDate = new DateTime(2013, 09, 09), EndDate = new DateTime(2013, 09, 16), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKZ3 Comdty", StartDate = new DateTime(2013, 10, 09), EndDate = new DateTime(2013, 10, 15), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKZ3 Comdty", StartDate = new DateTime(2013, 11, 09), EndDate = new DateTime(2013, 11, 15), StartHour = 7, EndHour = 18 });

      list.Add(new SetupItem { BbgTicker = "IKH4 Comdty", StartDate = new DateTime(2013, 12, 09), EndDate = new DateTime(2013, 12, 16), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKH4 Comdty", StartDate = new DateTime(2014, 01, 08), EndDate = new DateTime(2014, 01, 15), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKH4 Comdty", StartDate = new DateTime(2014, 02, 10), EndDate = new DateTime(2014, 02, 17), StartHour = 7, EndHour = 18 });



      list.Add(new SetupItem { BbgTicker = "IKH13 Comdty", StartDate = new DateTime(2013, 01, 25), EndDate = new DateTime(2013, 02, 01), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKH13 Comdty", StartDate = new DateTime(2013, 02, 22), EndDate = new DateTime(2013, 03, 01), StartHour = 7, EndHour = 18 });

      list.Add(new SetupItem { BbgTicker = "IKM13 Comdty", StartDate = new DateTime(2013, 03, 22), EndDate = new DateTime(2013, 04, 02), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKM13 Comdty", StartDate = new DateTime(2013, 04, 23), EndDate = new DateTime(2013, 05, 02), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKM13 Comdty", StartDate = new DateTime(2013, 05, 27), EndDate = new DateTime(2013, 06, 03), StartHour = 7, EndHour = 18 });

      list.Add(new SetupItem { BbgTicker = "IKU13 Comdty", StartDate = new DateTime(2013, 06, 24), EndDate = new DateTime(2013, 07, 01), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKU13 Comdty", StartDate = new DateTime(2013, 07, 25), EndDate = new DateTime(2013, 08, 01), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKU13 Comdty", StartDate = new DateTime(2013, 08, 26), EndDate = new DateTime(2013, 09, 02), StartHour = 7, EndHour = 18 });

      list.Add(new SetupItem { BbgTicker = "IKZ3 Comdty", StartDate = new DateTime(2013, 09, 24), EndDate = new DateTime(2013, 10, 01), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKZ3 Comdty", StartDate = new DateTime(2013, 10, 25), EndDate = new DateTime(2013, 11, 01), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKZ3 Comdty", StartDate = new DateTime(2013, 11, 23), EndDate = new DateTime(2013, 12, 02), StartHour = 7, EndHour = 18 });

      list.Add(new SetupItem { BbgTicker = "IKH4 Comdty", StartDate = new DateTime(2013, 12, 24), EndDate = new DateTime(2014, 01, 02), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKH4 Comdty", StartDate = new DateTime(2014, 01, 25), EndDate = new DateTime(2014, 02, 03), StartHour = 7, EndHour = 18 });
      list.Add(new SetupItem { BbgTicker = "IKH4 Comdty", StartDate = new DateTime(2014, 02, 23), EndDate = new DateTime(2014, 03, 03), StartHour = 7, EndHour = 18 });

      foreach (var sec in list.Select(x => x.BbgTicker).Distinct())
      {
        foreach (var setup in list.Where(x => x.BbgTicker.Equals(sec)).OrderBy(x => x.StartDate))
        {
          var outputList = new BindingList<OutputItem>();

          var contract = Singleton<IntradayFuturesContracts>.Instance.Where(x => x.BbgTicker.Equals(setup.BbgTicker)).FirstOrDefault();

          if (contract == null) System.Diagnostics.Debugger.Break();

          var currentDate = setup.StartDate;

          while (currentDate <= setup.EndDate)
          {
            DateTime startLN = currentDate.AddHours(setup.StartHour);
            DateTime endLN = currentDate.AddHours(setup.EndHour);

            DateTime startUTC = startLN - LN_TZI.GetUtcOffset(startLN);
            DateTime endUTC = endLN - LN_TZI.GetUtcOffset(endLN);

            //if (startUTC != startLN)
            //  System.Diagnostics.Debugger.Break();

            var data = contract.GetPricesBetween(startUTC, endUTC);

            if (data != null && data.Length>0)
            {
              for (int i = 0; i < data.Length; ++i)
                outputList.Add(new OutputItem() { Ticker = contract.BbgTicker, GMT = data.Dates[i], LNT=TimeZoneInfo.ConvertTime(data.Dates[i],LN_TZI), Price = data.Data[i] });
            }

            currentDate = currentDate.AddDays(1d);
            while (currentDate.DayOfWeek == DayOfWeek.Saturday || currentDate.DayOfWeek == DayOfWeek.Sunday)
              currentDate = currentDate.AddDays(1d);

            //data.DisplayLineChart(setup.BbgTicker);
          }

          StringBuilder b = new StringBuilder();
          b.Append("Ticker,GMT,LN_Time,Price").AppendLine();

          foreach (var v in outputList.OrderByDescending(x => x.GMT))
          {
            b.Append(v.Ticker).Append(",").Append(v.GMT.ToString("dd-MMM-yyyy HH:mm:ss")).Append(",").Append(v.LNT.ToString("dd-MMM-yyyy HH:mm:ss")).Append(",").AppendLine(v.Price.ToString());
          }

          System.IO.FileInfo t = new System.IO.FileInfo(string.Format(@"c:\kalyan\{0}_{1}to{2}.csv", setup.BbgTicker, setup.StartDate.ToString("dd-MMM-yyyy"), setup.EndDate.ToString("dd-MMM-yyyy")));
          System.IO.StreamWriter writer = t.CreateText();
          writer.Write(b.ToString());
          writer.Close();

        }


      }

      
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:FuturesExtractForKalyan.cs

示例14: local_store_key

        //this will write the keys to the hard drive
        private static string local_store_key(string passed_data_store, string keyID, RSACryptoServiceProvider passed_provider)
        {
            System.IO.DirectoryInfo Working_dir = new System.IO.DirectoryInfo(passed_data_store);
            System.IO.DirectoryInfo Keys_Dir = new System.IO.DirectoryInfo(System.IO.Path.Combine(Working_dir.ToString(), "keys"));
            if (Working_dir.Exists)
            {
                //Directory is good for storage
                if (!Keys_Dir.Exists)
                {
                    try
                    {
                        Keys_Dir.Create();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        return e.ToString();
                    }
                }
            }
            else
            {
                try
                {
                    Working_dir.Create();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    return e.ToString();
                }
                //No keys directory
                try
                {
                    Keys_Dir.Create();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    return e.ToString();
                }
            }
            Working_dir = null;
            //Keys Dir should work now
            System.IO.FileInfo Key_file = new System.IO.FileInfo(Keys_Dir.ToString() + System.IO.Path.DirectorySeparatorChar + keyID + ".key");
            using (System.IO.StreamWriter sw = Key_file.CreateText())
            {
                sw.Write(BitConverter.ToString(passed_provider.ExportCspBlob(true)));
                Console.WriteLine("Key Stored in 'keys'");
                //Console.WriteLine(BitConverter.ToString(passed_provider.ExportCspBlob(true)));
                //Console.WriteLine();
                //Console.WriteLine(BitConverter.ToString(passed_provider.ExportCspBlob(true)).Replace("-", string.Empty));

            }
            return "yes";
        }
开发者ID:daberkow,项目名称:PHP_PublicKeyDemo,代码行数:57,代码来源:Main.cs

示例15: Main


//.........这里部分代码省略.........
                        outFile.WriteLine ("Func: " + "System.IO.DirectoryInfo.Delete()");
                        outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                        outFile.WriteLine ("Time: " + GetTime (now));
                        outFile.WriteLine ("Retv: " + "");
                        outFile.WriteLine ("Errc: " + "");
                        outFile.WriteLine ("Exce: " + GetException (exc));
                    }
                }
            } catch (Exception) {
            }

            try {
                try {
                    exc = null;
                    sr = null;
                    now = System.DateTime.Now;
                    sr = System.IO.File.OpenText (tempPath + "\\dummyFile6.txt");
                    sr.Close ();
                } catch (Exception e) {
                    exc = e;
                } finally {
                    outFile.WriteLine ("Name: " + tempPath + "\\dummyFile6.txt");
                    outFile.WriteLine ("Func: " + "System.IO.File.OpenText(String)");
                    outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                    outFile.WriteLine ("Time: " + GetTime (now));
                    outFile.WriteLine ("Retv: " + toString (sr));
                    outFile.WriteLine ("Errc: " + "");
                    outFile.WriteLine ("Exce: " + GetException (exc));
                }
                try {
                    exc = null;
                    sw = null;
                    now = System.DateTime.Now;
                    sw = System.IO.File.CreateText (tempPath + "\\dummyFile7.txt");
                    sw.Close ();
                } catch (Exception e) {
                    exc = e;
                } finally {
                    outFile.WriteLine ("Name: " + tempPath + "\\dummyFile7.txt");
                    outFile.WriteLine ("Func: " + "System.IO.File.CreateText(String)");
                    outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                    outFile.WriteLine ("Time: " + GetTime (now));
                    outFile.WriteLine ("Retv: " + toString (sw));
                    outFile.WriteLine ("Errc: " + "");
                    outFile.WriteLine ("Exce: " + GetException (exc));
                }
                try {
                    exc = null;
                    sw = null;
                    now = System.DateTime.Now;
                    sw = System.IO.File.AppendText (tempPath + "\\dummyFile8.txt");
                    sw.Close ();
                } catch (Exception e) {
                    exc = e;
                } finally {
                    outFile.WriteLine ("Name: " + tempPath + "\\dummyFile8.txt");
                    outFile.WriteLine ("Func: " + "System.IO.File.AppendText(String)");
                    outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                    outFile.WriteLine ("Time: " + GetTime (now));
                    outFile.WriteLine ("Retv: " + toString (sw));
                    outFile.WriteLine ("Errc: " + "");
                    outFile.WriteLine ("Exce: " + GetException (exc));
                }
                try {
                    exc = null;
                    fs = null;
开发者ID:uvbs,项目名称:Holodeck,代码行数:67,代码来源:TestApplication4.cs


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