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


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

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


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

示例1: readCities

 /// <summary>
 /// Считывает названия городов из файлов карт
 /// <para>Использует пути к файлам из class FilesDirectories</para>
 /// </summary>
 public void readCities(params string[] mapFiles)
 {
     CitiesList = new List<string>();
     for (int i = 0; i < mapFiles.Length; ++i)
     {
         System.IO.StreamReader file = new System.IO.StreamReader(mapFiles[i]);
         string mapType = file.ReadLine().ToLower();
         if (mapType.Contains("воздушная карта"))
         {
             string City;
             //Считывание Аэропортов
             while ((City = file.ReadLine()) != null)
             {
                 string[] RecordParts = City.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                 CitiesList.Add(RecordParts[0]);
             }
             file.Close();
         }
         if (mapType.Contains("наземная карта"))
         {
             string[] GroundCities;
             //Считывание Городов с графовой карты
             GroundCities = file.ReadLine().Split(new char[] { ' ', '\t', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
             file.Close();
             CitiesList.AddRange(GroundCities);
             CitiesList = CitiesList.Distinct<string>().ToList<string>();
         }
     }
     CitiesList.Sort();
 }
开发者ID:Koperfild,项目名称:-------,代码行数:34,代码来源:Cities.cs

示例2: FileVisionSource

            public FileVisionSource(string FileName, MsgService msgService)
                : base(msgService)
            {
                try
                {
                    Globals.SOURCE_NAME = FileName.Split(Path.DirectorySeparatorChar).Last().Split('.').First();
                    if (Constants.EVALUATE_SUCCESS_ENABLED /*&& Globals.FRAME_SIGN_HASH.Keys.Count==0*/ )
                    {
                        Globals.FRAME_SIGN_HASH = new Hashtable();
                        String line = null;
                        System.IO.StreamReader file = new System.IO.StreamReader(Constants.base_folder + "labels_" + Globals.SOURCE_NAME + ".txt");
                        while ((line = file.ReadLine()) != null)
                        {
                            string[] frameno_signno = line.Split(',');
                            if (frameno_signno.Length < 2)
                            {
                                file.Close();
                                throw new Exception("Invalid label file for " + Globals.SOURCE_NAME);
                            }

                            Globals.FRAME_SIGN_HASH.Add(frameno_signno[0], line);
                            Globals.FRAME_COUNT = long.Parse(line.Split(',').First())-1;
                        }
                        file.Close();
                    }

                    // Set up the capture graph
                    Configure(FileName);
                }
                catch
                {
                    Dispose();
                    throw;
                }
            }
开发者ID:adesproject,项目名称:ADES,代码行数:35,代码来源:Sources.cs

示例3: RefreshPreview

        /// <summary>
        /// Refresh preview (if needed). Dependends on current environment and changed ETag.
        /// The preview is valid for remote and local view.
        /// First call will always lead to preview.
        /// 
        /// /Files/LocalPreview/Server/Path-To-File/file.preview.ext
        /// /Files/LocalPreview/Server/Path-To-File/file.etag
        /// </summary>
        /// <param name="file"></param>
        public void RefreshPreview(File file)
        {
            _file = file;
            bool createEtag = false;
            string path = "Files/LocalPreview/" + _info.Hostname + "/" + _file.FilePath + ".etag";
            var isf = App.DataContext.Storage;
            {
                if (isf.FileExists(path))
                {
                    var reader = new System.IO.StreamReader(isf.OpenFile(path, System.IO.FileMode.Open));
                    if (reader.ReadToEnd() == _file.ETag)
                    {
                        reader.Close();
                        return;
                    }
                    reader.Close();
                }
                else
                {
                    createEtag = true;
                }
            }

            // create main type
            if (_enabled)
            {
                switch (_file.FileType.Split('/').First())
                {
                    case "text":
                        TextPreview();
                        break;
                    case "image":
                        ImagePreview();
                        break;
                    case "application":
                        // try PDF content fetch
                        TextContentPreview();
                        break;
                    default:
                        PreviewIcon(file.IsDirectory);
                        break;
                }
            }
            else
            {
                PreviewIcon();
                createEtag = false;
            }

            if (createEtag)
            {
                    var storagePath = System.IO.Path.GetDirectoryName(path);
                    if (!isf.DirectoryExists(storagePath)) isf.CreateDirectory(storagePath);
                    var stream = isf.CreateFile(path);
                    System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
                    writer.Write(_file.ETag);
                    writer.Close();
            }
        }
开发者ID:ErikPel,项目名称:windows-phone,代码行数:68,代码来源:FileMultiTileViewControl.xaml.cs

示例4: loadPlayListFile

        public ObservableCollection<Media> loadPlayListFile(string pathFile)
        {
            string line;
            string lineInfos;
            int advanced = 1;
            Media tmp = null;
            ObservableCollection<Media> playList = new ObservableCollection<Media>();

            System.IO.StreamReader file = new System.IO.StreamReader(pathFile);
            line = file.ReadLine();
            if (line == null)
            {
                file.Close();
                return playList;
            }
            if (line.IndexOf("#EXTM3U") == -1)
                advanced = 0;
            lineInfos = "";
            while ((line = file.ReadLine()) != null)
            {
                if (advanced == 1)
                {
                    if (line.IndexOf("#EXTINF:") != 0)
                    {
                        if (line.IndexOf("#EXTREM:") == -1)
                        {
                            try
                            {
                                tmp = _mediaCreator.Create(line);
                                playList.Add(tmp);
                                lineInfos = "";
                            }
                            catch (Exception e)
                            {
                                Debug.Add(e.ToString());
                            }
                        }
                    }
                    else
                        lineInfos = line.Substring(8);
                }
                else
                {
                    try
                    {
                        tmp = _mediaCreator.Create(line);
                        playList.Add(tmp);
                        lineInfos = "";
                    }
                    catch (Exception e)
                    {
                        Debug.Add(e.ToString());
                    }
                }
            }
            file.Close();
            return playList;
        }
开发者ID:alliaces,项目名称:MyWindowsMediaPlayer,代码行数:58,代码来源:playlistManager.cs

示例5: Markov

 public Markov(int randomnessLevel, string inputFileName, startForm controlForm)
 {
     k = randomnessLevel;
     keys = new Queue<string>(k);
     words = new List<string>();
     wordGroups = new Dictionary<string, List<string>>();
     statusForm = controlForm;
     string line;
     System.IO.StreamReader file = new System.IO.StreamReader(inputFileName);
     while ((line = file.ReadLine()) != null)
     {
         statusForm.status = "Reading input...";
         foreach(string s in line.Split(' '))
         {
             words.Add(cleanupString(s));
         }
     }
     file.Close();
     if (words.Count < (k + 1))
     {
         //To avoid trying to index outside of the array.  Just adds the first word k more times.
         //The output would have sucked anyway, so this won't throw it off very much.
         for (int i = 0; i < k; i++)
         {
             words.Add(words[0]);
         }
     }
     readWordGroups();
 }
开发者ID:yalue,项目名称:Markov-Text,代码行数:29,代码来源:Markov.cs

示例6: generateDmcColors

        public void generateDmcColors()
        {
            System.IO.StreamReader inFile = new System.IO.StreamReader(webPageDirectory);
            System.IO.StreamWriter outFile = new System.IO.StreamWriter(dmcDirectory, true);
            string line = "", dmc = "", name = "", color = "";

            while ((line = inFile.ReadLine()) != null)
            {
                if (line.Trim().StartsWith("<TD><FONT face=\"arial, helvetica, sans-serif\" size=2>") && !line.Trim().EndsWith("Select view")) //find dmc
                {
                    dmc = line.Trim().Split(new string[] { "<TD><FONT face=\"arial, helvetica, sans-serif\" size=2>" }, StringSplitOptions.None)[1];
                    dmc = dmc.Split(new string[] { "<" }, StringSplitOptions.None)[0];
                }
                else if (line.Trim().StartsWith("<TD noWrap><FONT face=\"arial, helvetica, sans-serif\" size=2>"))  //find name
                {
                    //issue with line continuation
                    name = line.Trim().Split(new string[] { "<TD noWrap><FONT face=\"arial, helvetica, sans-serif\" size=2>" }, StringSplitOptions.None)[1];
                    name = name.Split(new string[] { "<" }, StringSplitOptions.None)[0];
                    if (!line.Trim().EndsWith("</FONT></TD>"))
                    {
                        line = inFile.ReadLine();
                        name = name + " " + line.Trim().Split(new string[] { "<" }, StringSplitOptions.None)[0];
                    }
                }
                else if (line.Trim().StartsWith("<TD bgColor=") && line.Trim().Contains(">&nbsp;</TD>"))
                {
                    color = line.Trim().Split(new string[] { "<TD bgColor=" }, StringSplitOptions.None)[1];
                    color = color.Split(new string[] { ">" }, StringSplitOptions.None)[0];
                    outFile.WriteLine(dmc + ";" + name + ";" + color);
                }
            }
            inFile.Close();
            outFile.Close();
            Console.ReadLine();
        }
开发者ID:rabidllamaofdoom,项目名称:PixelXStitchy,代码行数:35,代码来源:ColorFinder.cs

示例7: LoadShop

        public static Shop LoadShop(int shopNum)
        {
            Shop shop = new Shop();
            using (System.IO.StreamReader Read = new System.IO.StreamReader(IO.Paths.ShopsFolder + "shop" + shopNum + ".dat")) {
                string[] ShopInfo = Read.ReadLine().Split('|');
                if (ShopInfo[0] != "ShopData" || ShopInfo[1] != "V2") {
                        Read.Close();
                        return null;
                }

                string[] info;
                ShopInfo = Read.ReadLine().Split('|');
                shop.Name = ShopInfo[0];
                shop.JoinSay = ShopInfo[1];
                shop.LeaveSay = ShopInfo[2];
                //shop.FixesItems = ShopInfo[3].ToBool();
                //for (int i = 1; i <= 7; i++) {
                for (int z = 0; z < Constants.MAX_TRADES; z++) {
                    info = Read.ReadLine().Split('|');
                    shop.Items[z].GetItem = info[0].ToInt();
                    //shop.Items[z].GetValue = info[1].ToInt();
                    shop.Items[z].GiveItem = info[1].ToInt();
                    shop.Items[z].GiveValue = info[2].ToInt();
                }
                //}
            }
            return shop;
        }
开发者ID:pzaps,项目名称:Server,代码行数:28,代码来源:ShopManager.cs

示例8: Main

        public static void Main(string[] args)
        {
            // https://projecteuler.net/problem=18
            // https://projecteuler.net/problem=67
            int size = 100;//size of triangle from inputFilePath
            int[][] triangle = new int[size][];
            for (int i = 0; i < size; i++)
                triangle [i] = new int[i + 1];

            string inputFilePath = "test67.txt";//source file
            var fileStream = new System.IO.FileStream (inputFilePath, System.IO.FileMode.Open);
            var file = new System.IO.StreamReader(fileStream, System.Text.Encoding.UTF8);
            int lineCounter = 0;
            string lineOfText;
            while ((lineOfText = file.ReadLine()) != null) {
                var values = lineOfText.Split(' ');
                for (int j = 0; j < triangle [lineCounter].Length; j++)
                    triangle [lineCounter] [j] = Int32.Parse (values [j]);
                lineCounter++;
            }
            file.Close ();
            fileStream.Close ();

            //go from the bottom of triangle to the top
            //replace value in the line with maximum sum path from the botoom of the triangle to this point
            for (int k = size-2; k >= 0; k--) {
                var currentMaxValues = MaxPathSum (triangle [k+1], triangle [k]);
                for (int r = 0; r < currentMaxValues.Length; r++)
                    triangle [k] [r] = currentMaxValues [r];
            }
            Console.WriteLine ("Maximum path sum - {0}", triangle[0][0]);
        }
开发者ID:bogdantkachenko,项目名称:project-euler,代码行数:32,代码来源:euler67.cs

示例9: GetWordSet

		/// <summary> Loads a text file and adds every line as an entry to a HashSet (omitting
		/// leading and trailing whitespace). Every line of the file should contain only 
		/// one word. The words need to be in lowercase if you make use of an
		/// Analyzer which uses LowerCaseFilter (like GermanAnalyzer).
		/// 
		/// </summary>
		/// <param name="wordfile">File containing the wordlist
		/// </param>
		/// <returns> A HashSet with the file's words
		/// </returns>
		public static System.Collections.Hashtable GetWordSet(System.IO.FileInfo wordfile)
		{
			System.Collections.Hashtable result = new System.Collections.Hashtable();
			System.IO.StreamReader freader = null;
			System.IO.StreamReader lnr = null;
			try
			{
				freader = new System.IO.StreamReader(wordfile.FullName, System.Text.Encoding.Default);
				lnr = new System.IO.StreamReader(freader.BaseStream, freader.CurrentEncoding);
				System.String word = null;
				while ((word = lnr.ReadLine()) != null)
				{
                    System.String trimedWord = word.Trim();
					result.Add(trimedWord, trimedWord);
				}
			}
			finally
			{
				if (lnr != null)
					lnr.Close();
				if (freader != null)
					freader.Close();
			}
			return result;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:35,代码来源:WordlistLoader.cs

示例10: TitleFillUp

        private static void TitleFillUp()
        {
            System.IO.StreamReader files = new System.IO.StreamReader(@"../../CodeResources/Files.txt");
            System.IO.StreamReader dependences = new System.IO.StreamReader(@"../../CodeResources/Dependences.txt");

            SortedDictionary<string, Node> independedFolders = new SortedDictionary<string, Node>();
            independedFolders.Add("TASKS_EXPLORER\n", new Node("TASKS_EXPLORER\n"));

            while (!files.EndOfStream) {
                string file = files.ReadLine();
                independedFolders.Add(file, new Node(file));
            }

            while (!dependences.EndOfStream) {
                string inp = dependences.ReadLine();
                inp = Regex.Replace(inp, @"\s+", " ");
                inp = Regex.Replace(inp, @"\\n+", "\n");
                string[] edge = inp.Split(' ');
                independedFolders[edge[0]].children.Add(independedFolders[edge[1]]);
                independedFolders[edge[0]].children[independedFolders[edge[0]].children.Count - 1].number = independedFolders[edge[0]].children.Count - 1;
                independedFolders[edge[0]].children[independedFolders[edge[0]].children.Count - 1].parent = independedFolders[edge[0]];
            }

            folders = independedFolders["TASKS_EXPLORER\n"];

            files.Close();
            dependences.Close();
        }
开发者ID:Praytic,项目名称:csharp-basics,代码行数:28,代码来源:ConsoleInterface.cs

示例11: CreateRegex

        static Regex lineSimpleApply = CreateRegex(@"^Ext.apply\(\s*(?<name>({id}\.)?{idx})(\.prototype)?.*"); // e.g. Ext.apply(Dextop.common, {

        #endregion Fields

        #region Methods

        public override void ProcessFile(String filePath, Dictionary<String, LocalizableEntity> map)
        {
            ClasslikeEntity jsObject = null;
            System.IO.TextReader reader = new System.IO.StreamReader(filePath, Encoding.UTF8);
            //Logger.LogFormat("Processing file {0}", filePath);
            try
            {
                while (reader.Peek() > 0)
                {
                    String line = reader.ReadLine();
                    ClasslikeEntity o = ProcessExtendLine(filePath, line);
                    if (o != null)
                        jsObject = o;

                    else if (jsObject != null) {
                        LocalizableEntity prop = ProcessPropertyLine(jsObject, line);
                        if (prop != null && !map.ContainsKey(prop.FullEntityPath))
                            map.Add(prop.FullEntityPath, prop);
                    }
                }
                Logger.LogFormat("Processing file {0} - Success", filePath);
            }
            catch (Exception ex)
            {
                Logger.LogFormat("Processing file {0} - Error", filePath);
                throw ex;
            }
            finally
            {
                reader.Close();
            }
        }
开发者ID:borisdj,项目名称:dextop-localizer,代码行数:38,代码来源:JsExtractor.cs

示例12: 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

示例13: ExecuteCmdlet

        protected override void ExecuteCmdlet()
        {
            WebPartEntity wp = null;

            if (ParameterSetName == "FILE")
            {
                if (System.IO.File.Exists(Path))
                {
                    System.IO.StreamReader fileStream = new System.IO.StreamReader(Path);
                    string webPartString = fileStream.ReadToEnd();
                    fileStream.Close();

                    wp = new WebPartEntity();
                    wp.WebPartZone = ZoneId;
                    wp.WebPartIndex = ZoneIndex;
                    wp.WebPartXml = webPartString;
                }
            }
            else if (ParameterSetName == "XML")
            {
                wp = new WebPartEntity();
                wp.WebPartZone = ZoneId;
                wp.WebPartIndex = ZoneIndex;
                wp.WebPartXml = Xml;
            }
            if (wp != null)
            {
                this.SelectedWeb.AddWebPartToWebPartPage(PageUrl, wp);
            }
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:30,代码来源:AddWebPartToWebPartPage.cs

示例14: PassWordModify

        /// <summary>
        /// �޸��û�����
        /// </summary>
        /// <param name="strNewPass">������</param>
        /// <returns>-100 �û������������</returns>
        public string PassWordModify(string strNewPass)
        {
            //��ȡϵͳ������Ϣ
            SystemConfig config = SystemConfig.GetSettings();
            string strRequst = "";
            try
            {
                Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
                string strTemp = "http://221.0.225.126:81/sendsms/modify?User=" + HttpUtility.UrlEncode(config.NoteConfig.UserName, encode)
                    + "&Pass=" + HttpUtility.UrlEncode(config.NoteConfig.Password, encode)
                    + "&NewPass=" + HttpUtility.UrlEncode(strNewPass, encode);
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(strTemp);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream(), encode);
                strRequst = reader.ReadToEnd();
                reader.Close();
                response.Close();

                //д�������ļ�
                SystemConfig systemConfig = new SystemConfig();
                systemConfig.NoteConfig = config.NoteConfig;
                systemConfig.NoteConfig.Password = strNewPass;
                systemConfig.SaveSettings();
            }
            catch
            {
            }
            return strRequst;
        }
开发者ID:wanghouxian2015,项目名称:GMWJGit,代码行数:35,代码来源:SMSNoteManage.cs

示例15: readFromFile

 public static List<TileBehavior> readFromFile(string fileName)
 {
     List<TileBehavior> behaviors = new List<TileBehavior>();
     try
     {
         System.IO.StreamReader sr = new System.IO.StreamReader(fileName);
         while (!sr.EndOfStream)
         {
             string line = sr.ReadLine();
             if (line != string.Empty) {
                 if (line.StartsWith("+"))
                     behaviors.Add(new TileBehavior("", line.Substring(1)));
                 else {
                     int equalpos = line.IndexOf('=');
                     behaviors.Add(new TileBehavior(line.Substring(0, equalpos - 1).Trim(), line.Substring(equalpos + 1).Trim()));
                 }
             }
         }
         sr.Close();
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show("Error reading tile behavior file. The error is: \n" + ex.Message);
     }
     return behaviors;
 }
开发者ID:JaviLuki,项目名称:NSMB-Editor,代码行数:26,代码来源:TileBehavior.cs


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