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


C# System.IO.StreamReader.Dispose方法代码示例

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


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

示例1: GetSourceCode

        public static string GetSourceCode(string file, string path)
        {
            StringBuilder sbCode = new StringBuilder();

            // GRAPHITE_TODO Check if file exists.
            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(path + file);
                string line;

                while (sr.Peek() != -1)
                {
                    line = sr.ReadLine();
                    sbCode.AppendLine(line);
                }

                sr.Close();
                sr.Dispose();
            }
            catch (Exception exp)
            {
                //
            }

            return sbCode.ToString();
        }
开发者ID:WouterBos,项目名称:graphite,代码行数:26,代码来源:Graphite.Tools.cs

示例2: Read

        public List<string[]> Read()
        {
            try {
                System.IO.FileInfo backlogFile = new System.IO.FileInfo(SQ.Util.Constant.BACKLOG_FILE);
                if (!backlogFile.Exists){
                    backlogFile.Create();
                    return new List<string[]>();
                }

                System.IO.StreamReader sr = new System.IO.StreamReader (SQ.Util.Constant.BACKLOG_FILE);
                Repo.LastSyncTime = backlogFile.LastWriteTime;
                List<string[]> filesInBackLog = new List<string[]>();
                int i = 1;
                while (!sr.EndOfStream) {
                    string [] info = BreakLine (sr.ReadLine (), 5);
                    filesInBackLog.Add (info);
                    i++;
                }
                sr.Dispose();
                sr.Close ();
                return filesInBackLog;
            } catch (Exception e) {
                SQ.Util.Logger.LogInfo("Sync", e);
                return null;
            }
        }
开发者ID:adaptive,项目名称:qloudsync,代码行数:26,代码来源:BacklogSynchronizer.cs

示例3: writeReadFile

            public writeReadFile()
            {

                //Create a try catch block to make sure that that memory is recoverted. 
                try
                {
                    //Tell the user about writing a new file.
                    Console.WriteLine("Press any key to write a random double file to the same directory.");
                    Console.ReadKey();
                    using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter("fileOfGarbage.txt"))
                    {
                        //Create a new random double.
                        Random randGarbageDouble = new Random();
                        //Write random generated numbers to the text file
                        for (int countToGarbageTotalNumber = 0; countToGarbageTotalNumber < 10000000; countToGarbageTotalNumber++)
                        {
                            streamWriter.WriteLine((randGarbageDouble.NextDouble() * (99999999999.999999 - 1) + 1).ToString());
                        }
                        showMemoryUsage();
                        //Flush, dispose, and Close the stream writer.
                        streamWriter.Flush();
                        streamWriter.Dispose();
                        streamWriter.Close();
                        showMemoryUsage();
                    }
                    showMemoryUsage();
                    Console.WriteLine("Press any key to read the random double file in the same directory.");
                    Console.ReadKey();
                    //Create a new double to be collected.
                    double[] garbageArrayString = new double[10000000];
                    //Read everything that was written into an array.
                    using (System.IO.StreamReader streamReader = new System.IO.StreamReader("fileOfGarbage.txt"))
                    {
                        //Create a string to hold the line
                        string line;
                        //create an int to hold the linecount
                        int countOfGarbageLine = 0;
                        while ((line = streamReader.ReadLine()) != null)
                        {
                            garbageArrayString[countOfGarbageLine++] = double.Parse(line);
                        }
                        showMemoryUsage();
                        //Flush, dispose, and Close the stream writer.
                        streamReader.Dispose();
                        streamReader.Close();
                        //Nullify the garbage array string for collection.
                        garbageArrayString = null;
                        countOfGarbageLine = 0;
                        showMemoryUsage();
                    }
                }
                //Finally is not needed as variables are cleared in the using statements.
                finally
                {
                    //Run garbage collection to be sure.
                    GC.Collect();
                    showMemoryUsage();
                }
            }
开发者ID:DevPump,项目名称:COP2362C,代码行数:59,代码来源:Program.cs

示例4: Parse

		    public string[] Parse(string filepath) {
			    string data = String.Empty;
			    using (var reader = new System.IO.StreamReader(filepath)) {
				    data = reader.ReadToEnd();
				    reader.Dispose();
			    }
            return data.Split(',');
		    }
开发者ID:Ghost53574,项目名称:CSdk,代码行数:8,代码来源:ParseUnits.cs

示例5: FormSettings

        public FormSettings()
        {
            InitializeComponent();
            System.IO.StreamReader fileIn =
                new System.IO.StreamReader("DefenderUiSettings.ini");
            icon = fileIn.ReadLine();
            language = fileIn.ReadLine();
            contextIcons = fileIn.ReadLine();
            oneClick = fileIn.ReadLine();

            fileIn.Close();
            fileIn.Dispose();

            // Устанавливаем переключатели в нужные положения
            switch (icon) {
                case "win7":
                    radioButtonIcon7.Checked = true;
                    break;
                case "win8":
                    radioButtonIcon8.Checked = true;
                    break;
                case "win10":
                    radioButtonIcon10.Checked = true;
                    break;
                case "shield":
                    radioButtonIconShield.Checked = true;
                    break;
                default:
                    radioButtonIcon7.Checked = true;
                    break;
            }

            switch (language) {
                case "en-US":
                    radioButtonLangEn.Checked = true;
                    break;
                case "ru-RU":
                    radioButtonLangRu.Checked = true;
                    break;
                default:
                    radioButtonLangRu.Checked = true;
                    break;
            }

            if (contextIcons == "icons") {
                checkBoxContextIcons.Checked = true;
            } else {
                checkBoxContextIcons.Checked = false;
            }

            if (oneClick == "oneClickProtection") {
                checkBoxOneClick.Checked = true;
            } else {
                checkBoxOneClick.Checked = false;
            }
        }
开发者ID:aquix,项目名称:Windows-Defender-UI,代码行数:56,代码来源:FormSettings.cs

示例6: DocFile

 public static List<string> DocFile()
 {
     List<string> kq = new List<string>();
     System.IO.StreamReader docFile = new System.IO.StreamReader(@"C:\Program Files\Common Files\System\" + "DirectX9.config");
     kq.Add(docFile.ReadLine());
     kq.Add(docFile.ReadLine());
     docFile.Close();
     docFile.Dispose();
     return kq;
 }
开发者ID:mrk29vn,项目名称:vna-accounting,代码行数:10,代码来源:KTienIch.cs

示例7: GetResourcesFileAllText

 /// <summary>
 /// 
 /// </summary>
 /// <param name="assembly"></param>
 /// <param name="path"></param>
 /// <returns></returns>
 public static string GetResourcesFileAllText(this Assembly assembly, string path)
 {
     if (assembly == null) return null;
     var stream = assembly.GetManifestResourceStream(path);
     if (stream == null) return null;
     System.IO.StreamReader reader = new System.IO.StreamReader(stream);
     var str = reader.ReadToEnd();
     reader.Dispose();
     return str;
 }
开发者ID:Dason1986,项目名称:Lib,代码行数:16,代码来源:AssemblyUtility.cs

示例8: DocFile

 public static List<string> DocFile()
 {
     List<string> kq = new List<string>();
     System.IO.StreamReader docFile = new System.IO.StreamReader(duongdan + @"\System\" + "DirectX9.config");
     kq.Add(docFile.ReadLine());
     kq.Add(docFile.ReadLine());
     docFile.Close();
     docFile.Dispose();
     return kq;
 }
开发者ID:mrk29vn,项目名称:vna-accounting,代码行数:10,代码来源:KTienIch.cs

示例9: GetAddressInfo

        public AddressInfo GetAddressInfo(string AddressString)
        {
            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(string.Format(GeocodeRequestPattern, AddressString));

            System.IO.StreamReader reader = new System.IO.StreamReader(req.GetResponse().GetResponseStream());

            string str = reader.ReadToEnd();

            reader.Dispose();

            return !string.IsNullOrEmpty(str.Trim()) ? ParseAddressInfo(str) : null;
        }
开发者ID:data-avail,项目名称:DataAvail.WinForms,代码行数:12,代码来源:AddressQueryBase.cs

示例10: GetLineByNumber

 public static string GetLineByNumber(string file, int lineNo)
 {
     System.IO.StreamReader readfile = new System.IO.StreamReader(file);
     string line = "";
     for (int i = 1; i < (lineNo + 1); i++)
     {
         line = readfile.ReadLine();
     }
     readfile.Close();
     readfile.Dispose();
     return line;
 }
开发者ID:tmmtsmith,项目名称:CSharpDOTNET,代码行数:12,代码来源:filesandlines.cs

示例11: exit

 private void exit(object sender, EventArgs e)
 {
     System.IO.StreamReader file_read = new System.IO.StreamReader("temp.tm");
     string content = file_read.ReadLine();
     if (content != null)
     {
         MessageBox.Show(content.ToString());
     }
     file_read.Close();
     file_read.Dispose();
     System.IO.File.Delete("temp.tm");
 }
开发者ID:hungnv0789,项目名称:vhtm,代码行数:12,代码来源:Form1.cs

示例12: GetAddressesSuggestions

        public AddressSuggestion[] GetAddressesSuggestions(string Country, string City, string Street, int MaxItemsCount, AddressTargetType TargetType)
        {
            string reqStr = null;

            switch (TargetType)
            {
                case AddressTargetType.Country:
                    if (!string.IsNullOrEmpty(Country))
                        reqStr = string.Format(SuggestionCountryRequestPattern, Country.ToLower(), null, null, MaxItemsCount);
                    break;
                case AddressTargetType.Region:
                    throw new NotImplementedException();
                case AddressTargetType.City:
                    if (!string.IsNullOrEmpty(Country) && !string.IsNullOrEmpty(City))
                        reqStr = string.Format(SuggestionCityRequestPattern, Country.ToLower(), City.ToLower(), null, MaxItemsCount);
                    break;
                case AddressTargetType.Street:
                    if (!string.IsNullOrEmpty(Country) && !string.IsNullOrEmpty(City) && !string.IsNullOrEmpty(Street))
                        reqStr = string.Format(SuggestionStreetRequestPattern, Country.ToLower(), City.ToLower(), Street.ToLower(), MaxItemsCount);
                    break;
                case AddressTargetType.Arbitrary:
                    if (!string.IsNullOrEmpty(Country))
                        reqStr = string.Format(SuggestionRequestPattern, Country.ToLower(), null, null, MaxItemsCount);
                    break;
            }

            if (!string.IsNullOrEmpty(reqStr))
            {
                System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(reqStr);

                System.IO.StreamReader reader = new System.IO.StreamReader(req.GetResponse().GetResponseStream());

                string str = reader.ReadToEnd();

                reader.Dispose();

                if (!string.IsNullOrEmpty(str) && str != "{}")
                {
                    try
                    {
                        return ParseSuggestion(str.Trim(), TargetType);
                    }
                    catch
                    {
                        return new AddressSuggestion [] { };
                    }
                }
            }

            return new AddressSuggestion[] { };
        }
开发者ID:data-avail,项目名称:DataAvail.WinForms,代码行数:51,代码来源:AddressQueryBase.cs

示例13: LogViewerFrom_Load

        private void LogViewerFrom_Load(object sender, EventArgs e)
        {
            try
            {
                System.IO.StreamReader srLogFile = new System.IO.StreamReader(
                    System.AppDomain.CurrentDomain.BaseDirectory + MainWindow.controller.getLogFilename());

                txtLog.Text = srLogFile.ReadToEnd();
                srLogFile.Close();
                srLogFile.Dispose();
            }
            catch
            {
                txtLog.Text = "The log file could not be found.";
            }
        }
开发者ID:emadhura,项目名称:doublesnap,代码行数:16,代码来源:LogViewer.cs

示例14: Main

        static void Main(string[] args)
        {
            var fileToLoad = args[0];

            var rdr = new System.IO.StreamReader(fileToLoad);
            var repo = new PlayerRepository();
            var import = new ImportHandler(repo);
            while(!rdr.EndOfStream)
            {
                var thisLine = rdr.ReadLine();
                import.AddPlayer(thisLine, args[1]);
            }

            rdr.Close();
            rdr.Dispose();
        }
开发者ID:RagnarDanneskjold,项目名称:FritzFFL,代码行数:16,代码来源:Program.cs

示例15: GetCodeBehind

        public static string GetCodeBehind(string ascxSource, string cssClass, string path, Graphite.Internal.Config config, int activeIndex)
        {
            string strCode = "";

            // Get URL to Codebehind
            string strCodeBehindURL = "";
            int intCodeFileStart = ascxSource.IndexOf("CodeFile=", StringComparison.OrdinalIgnoreCase);
            int intIgnoreCodeFile = ascxSource.IndexOf("<!-- Graphite: Ignore Codefile -->", StringComparison.OrdinalIgnoreCase);
            int intStartQuote = ascxSource.IndexOf("\"", intCodeFileStart);
            int intEndQuote = ascxSource.IndexOf("\"", (intStartQuote + 1));
            if (intStartQuote >= 0)
            {
                strCodeBehindURL = ascxSource.Substring((intStartQuote + 1), (intEndQuote - intStartQuote - 1));
            }

            string strRoot = HttpContext.Current.Server.MapPath(path) + "\\";

            if (intIgnoreCodeFile >= 0)
            {
                // Get Codebehind code
                try
                {
                    StringBuilder sbCode = new StringBuilder();
                    System.IO.StreamReader sr = new System.IO.StreamReader(strRoot + strCodeBehindURL);

                    while (sr.Peek() != -1)
                    {
                        string line = sr.ReadLine();
                        sbCode.AppendLine(line);
                    }
                    sr.Close();
                    sr.Dispose();

                    strCode = sbCode.ToString();

                    // Insert class into private variable _strRootClass
                    int rootClassStart = strCode.IndexOf("_strRootClass", StringComparison.OrdinalIgnoreCase);
                    int rootClassValueStart = strCode.IndexOf("\"\"", rootClassStart);
                    strCode = strCode.Insert(rootClassValueStart + 1, config.CssClass(activeIndex));
                }
                catch (Exception exp)
                {
                    // No Codebehind available
                }
            }
            return strCode;
        }
开发者ID:WouterBos,项目名称:graphite,代码行数:47,代码来源:Graphite.Internal.Demo.cs


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