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


C# FileInfo.OpenText方法代码示例

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


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

示例1: Start

    // Use this for initialization
    void Start()
    {
        originalFile = new FileInfo(Application.dataPath + "/questions.txt");
        if (originalFile != null && originalFile.Exists)
        {
            reader = originalFile.OpenText();
        }
        else
        {
            textfile = (TextAsset)Resources.Load("embedded2", typeof(TextAsset));
            reader = new StringReader(textfile.text);
        }

        string lineOfText;
        int lineNumber = 0;

        while ((lineOfText = reader.ReadLine()) != null)
        {
            lineOfText = lineOfText.Replace("''", "'");
            if (lineNumber%5 == 0)
                questions.Add(lineOfText);
            else
                answers.Add(lineOfText);
            lineNumber++;
        }

        SendMessage("Gather");
    }
开发者ID:CBroskow,项目名称:Lab04,代码行数:29,代码来源:TriviaLoadScript.cs

示例2: LoadMapping

    void LoadMapping()
    {
        FileInfo theSourceFile = new FileInfo (path);
        StreamReader reader = theSourceFile.OpenText();

        string text = reader.ReadToEnd();
        reader.Close();
        string[] lines = text.Split('\r');

        Client_lowerLeft_x = float.Parse(lines[1]);
        Client_lowerLeft_y = float.Parse(lines[2]);
        Client_lowerRight_x = float.Parse(lines[3]);
        Client_lowerRight_y = float.Parse(lines[4]);
        Client_upperRight_x = float.Parse(lines[5]);
        Client_upperRight_y = float.Parse(lines[6]);
        Client_upperLeft_x = float.Parse(lines[7]);
        Client_upperLeft_y = float.Parse(lines[8]);

        Server_lowerLeft_x = float.Parse(lines[10]);
        Server_lowerLeft_y = float.Parse(lines[11]);
        Server_lowerRight_x = float.Parse(lines[12]);
        Server_lowerRight_y = float.Parse(lines[13]);
        Server_upperRight_x = float.Parse(lines[14]);
        Server_upperRight_y = float.Parse(lines[15]);
        Server_upperLeft_x = float.Parse(lines[16]);
        Server_upperLeft_y = float.Parse(lines[17]);
    }
开发者ID:merlinsaw,项目名称:diplom,代码行数:27,代码来源:QuadMapping.cs

示例3: Start

    void Start()
    {
        introText = "";
        showIntroText = true;
        intro = new ArrayList();

        FileInfo theSourceFile = new FileInfo("Assets/StoryAssets/Level1.txt");
        StreamReader reader = theSourceFile.OpenText();
        SpeechBubbleText = GameObject.FindWithTag("SpeechBubbleText").GetComponent<GUIText>() as GUIText;
        string line;
        int i = 0;
        currentLine = 0;

        do
        {
            line = reader.ReadLine();
            intro.Add(line);
            i++;
        } while (line != null);

        do
        {
            if (currentLine >= 5)
            {
                showIntroText = false;
            }

            SpeechBubbleText.text = (intro[currentLine]).ToString();
            StartCoroutine(HideSpeechBubble());
        } while (showIntroText == true);
    }
开发者ID:Rameos,项目名称:PSMG_Alarm,代码行数:31,代码来源:StorySequenceScript.cs

示例4: Start

    void Start()
    {
        originalFile = new FileInfo(Application.dataPath + "/sentences.txt");

        if(originalFile != null && originalFile.Exists)
        {
            reader = originalFile.OpenText();
        }
        else
        {
            textFile = (TextAsset)Resources.Load("embedded", typeof(TextAsset));
            reader = new StringReader(textFile.text);
        }

        string lineOfText;
        int lineNumber = 0;

        while((lineOfText = reader.ReadLine()) != null)
        {
            if(lineNumber %2 == 0)
            {
                //even lines
                sentences.Add(lineOfText);
            }
            else
            {
                //odd lines
                clues.Add(lineOfText);
            }

            lineNumber++;
        }

        SendMessage("Gather");
    }
开发者ID:deluxturtle,项目名称:Lab04,代码行数:35,代码来源:LoadScript.cs

示例5: create_style

 public StringBuilder create_style(String type)
 {
     FileInfo xmlfile = new FileInfo(HttpContext.Current.Server.MapPath("~/App_Data/Styles/style.xml"));
     StringBuilder sb = new StringBuilder(xmlfile.OpenText().ReadToEnd());
     sb.Replace("@[email protected]", type);
     return sb;
 }
开发者ID:Geoneer,项目名称:GeoExplorer,代码行数:7,代码来源:Geoserver.cs

示例6: count

    // Some comment for the test
    private void count(string root)
    {
        foreach (string newRoot in Directory.GetDirectories(root))
        {
            count(newRoot);
        }

        foreach (string filePath in Directory.GetFiles(root))
        {
            FileInfo fi = new FileInfo(filePath);
            if(fi.Extension.Equals(".cs"))
            {
                int cnt = 0;
                StreamReader reader = fi.OpenText();
                string line;
                bool commentBlock = false;
                while((line = reader.ReadLine()) != null)
                {
                    if(!commentBlock && !lineComment.IsMatch(line))
                    {
                        if(commentBlockStart.IsMatch(line))
                        {
                            commentBlock = true;
                        } else if (!emptyLine.IsMatch(line)) {
                            cnt++;
                        }
                    } else if (commentBlockEnd.IsMatch(line)) {
                        commentBlock = false;
                    }
                }
                Console.WriteLine("{0} got {1} lines with code", filePath, cnt);
            }
        }
    }
开发者ID:seniorivn,项目名称:ITMO,代码行数:35,代码来源:task3.cs

示例7: Start

    // Use this for initialization
    void Start()
    {
        originalFile = new FileInfo (Application.dataPath + "/sentences.txt");

        if (originalFile != null && originalFile.Exists)
        {
            reader = originalFile.OpenText ();
        }
        else
        {
            textFile = (TextAsset)Resources.Load ("embedded", typeof(TextAsset));
            reader = new StringReader (textFile.text);
        }

        string lineOfText;
        int lineNumber = 0;

        //tell teh reader to read a line of text, and store that in the line of TextVariable
        //continue doing this until there are no lines left
        while ((lineOfText = reader.ReadLine ()) != null)
        {
            if(lineNumber%2 == 0)
            {
                sentences.Add (lineOfText);
            }
            else
            {
                clues.Add (lineOfText);
            }
            lineNumber++;
        }

        SendMessage ("Gather");
    }
开发者ID:sandrockman,项目名称:Lab04,代码行数:35,代码来源:LoadScript.cs

示例8: ExportGrid

    private void ExportGrid(string fileName, string contentType)
    {
        Response.Clear();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
        Response.Charset = "";
        Response.ContentType = contentType;

        StringWriter sw = new StringWriter();
        HtmlTextWriter HW = new HtmlTextWriter(sw);


        // Read Style file (css) here and add to response 
        FileInfo fi = new FileInfo(Server.MapPath(".") + "\\styles\\myGrid.css");
        StringBuilder sb = new StringBuilder();
        StreamReader sr = fi.OpenText();
        while (sr.Peek() >= 0)
        {
            sb.Append(sr.ReadLine());
        }
        sr.Close();

        grid1.RenderControl(HW);
        Response.Write("<html><head><style type='text/css'>" + sb.ToString() + "</style></head><body>" + sw.ToString() + "</body></html>");
        Response.Flush();
        Response.Close();
        Response.End();
    }
开发者ID:spetluru,项目名称:MSMEtools,代码行数:28,代码来源:ViewFeedback.aspx.cs

示例9: Button1_Click

    //this is our receive button they press this to update there news
    protected void Button1_Click(object sender, EventArgs e)
    {
        //this is where they are getting there news
        const string Path = @"C:\Users\Dan the man\Desktop\news.txt";

        //this is to id the path
        FileInfo newsstuff = new FileInfo(Path);
        //we use the following to get the data from the file
        using (StreamReader sRead = newsstuff.OpenText()) {
            //we have a loop that continues untill there is no more data
            while (!sRead.EndOfStream)
            {
                    //we add the items to the listbox for each line in the file
                    ListBox1.Items.Add(sRead.ReadLine());
                    //we want to only display ten so we delete once we are past that amount
                    if (this.ListBox1.Items.Count == 10)
                    {
                        this.ListBox1.Items.RemoveAt(1);
                    
                    }

            }
            //this closes everything
            sRead.Close();
        }

    }
开发者ID:dandanjoseph,项目名称:News-Chat-Room,代码行数:28,代码来源:Form.aspx.cs

示例10: SelectTextFile

 public void SelectTextFile(string file)
 {
     if (file == "FirstScene") {
         fileName = file;
         theSourceFile = new FileInfo ("Assets/Scripts/Dialogue/FirstScene.txt");
         reader = theSourceFile.OpenText ();
         startText = true;
     } else if (file == "Level1End") {
         fileName = file;
         theSourceFile = new FileInfo ("Assets/Scripts/Dialogue/Level1End.txt");
         reader = theSourceFile.OpenText ();
         startText = true;
     } else if (file == "GoodEnding") {
         fileName = file;
         theSourceFile = new FileInfo ("Assets/Scripts/Dialogue/FinalDialogues/GoodEnding.txt");
         reader = theSourceFile.OpenText ();
         startText = true;
     } else if (file == "BadEnding") {
         fileName = file;
         theSourceFile = new FileInfo ("Assets/Scripts/Dialogue/FinalDialogues/BadEnding.txt");
         reader = theSourceFile.OpenText ();
         startText = true;
     } else {
         theSourceFile = null;
     }
 }
开发者ID:Archimedyz,项目名称:COMP_376_Project,代码行数:26,代码来源:Dialogue.cs

示例11: Start

    void Start()
    {
        triviaFile = new FileInfo(Application.dataPath + "/trivia.txt");

        if (triviaFile != null && triviaFile.Exists) {
            reader = triviaFile.OpenText();
        } else {
            embedded = (TextAsset) Resources.Load("trivia_embedded", typeof (TextAsset));
            reader = new StringReader(embedded.text);
        }

        string lineOfText = "";
        int lineNumber = 0;

        while ( ( lineOfText = reader.ReadLine() ) != null ) {

            string question = lineOfText;
            int answerCount = Convert.ToInt32(reader.ReadLine());
            List<string> answers = new List<string>();
            for (int i = 0; i < answerCount; i++) {
                answers.Add(reader.ReadLine());
            }

            Trivia temp = new Trivia(question, answerCount, answers);

            triviaQuestions.Add(temp);
            lineNumber++;
        }

        SendMessage( "BeginGame" );
    }
开发者ID:LivingValkyrie,项目名称:Lab04,代码行数:31,代码来源:TriviaLoader.cs

示例12: featuretype_create

 public StringBuilder featuretype_create(string featuretype_name)
 {
     FileInfo xmlfile = new FileInfo(HttpContext.Current.Server.MapPath("~/App_Data/featuretype.xml"));
     StringBuilder sb = new StringBuilder(xmlfile.OpenText().ReadToEnd());
     sb.Replace("@[email protected]", featuretype_name);
     return sb;
 }
开发者ID:Geoneer,项目名称:GeoExplorer,代码行数:7,代码来源:Geoserver.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        engine = Camera.main.GetComponent<ScriptEngine>();

        originalFile = new FileInfo(Application.dataPath + "/questions.txt");

        if(originalFile != null && originalFile.Exists)
        {
            reader = originalFile.OpenText();
        }
        else
        {
            textFile = (TextAsset)Resources.Load("embedded", typeof(TextAsset));
            reader = new StringReader(textFile.text);
        }

        string lineOfText;
        int lineNumber = 0;

        while((lineOfText = reader.ReadLine()) != null)
        {
            if(lineNumber % 2 == 0)
            {
                questions.Add(lineOfText);
            }
            else
            {
                answers.Add(lineOfText);
            }
            lineNumber++;
        }

        engine.RunGame(questions, answers);
    }
开发者ID:mdobson2,项目名称:Lab04,代码行数:35,代码来源:ModDataScript.cs

示例14: Parse

    // this funtion reads in the file that you designate, and parses it in appropriately.
    public bool Parse()
    {
        properties = new List<string> ();
        allData = new List<ProbData> ();

        FileInfo file = new FileInfo (filename);

        if (file.Exists)
        {
            StreamReader reader = file.OpenText ();

            string currLine;
            string[] foundProps;
            currLine = reader.ReadLine ();
            foundProps = currLine.Split ('\t');
            for(int ii = 0; ii < foundProps.Length - 1; ii++)
            {
                properties.Add(foundProps[ii]);
            }

            float lastIndex = 0;

            while(!reader.EndOfStream)
            {
                currLine = reader.ReadLine();
                string[] data;
                data = currLine.Split('\t');

                ProbData newObj = new ProbData(data.Length - 1);

                for(int xx = 0; xx < data.Length -1; xx++)
                {
                    newObj.properties.Set (xx, (data[xx].ToUpper ().CompareTo("Y") == 0));
                }

                float prob = float.Parse (data[data.Length - 1]);
                prob += lastIndex;
                lastIndex = prob;
                newObj.probabilityCap = prob;

                allData.Add (newObj);

                print (newObj.ToString());
            }

            allData = allData.OrderBy(i => i.probabilityCap).ToList();

            print ("Parsing Complete");
            return true;
        }
        else
        {
            print ("File Not Found! " + file.FullName);
        }

        return false;
    }
开发者ID:nthacker12,项目名称:AIExample,代码行数:58,代码来源:Parser.cs

示例15: ImportLevel

    public void ImportLevel(string pLevelName)
    {
        FileInfo levelReadingData = new FileInfo(Application.dataPath + "/" + FindLevel(pLevelName));
        reader = levelReadingData.OpenText();

        string input = reader.ReadToEnd();
        reader.Close();

        File.WriteAllText(Application.dataPath + "/waypoints.txt", input);
    }
开发者ID:nboehning,项目名称:Project-03---User-Rails,代码行数:10,代码来源:ScriptLoad.cs


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