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


C# FileInfo.Equals方法代码示例

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


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

示例1: Start

    void Start()
    {
        originalFile = new FileInfo(Application.dataPath + "/sentences.txt");
        // Check if a user provided file exists
        // If file exists, read data from the file
        if (!originalFile.Equals(null) && originalFile.Exists)
        {
            reader = originalFile.OpenText();
        }
        // If file doesn't exist, read from the embedded game file
        else
        {
            textFile = (TextAsset)Resources.Load("embedded", typeof(TextAsset));
            reader = new StringReader(textFile.text);
        }

        string lineOfText;
        int lineNumber = 0;

        // Read from the reader file while there is still data in the file
        while((lineOfText = reader.ReadLine()) != null)
        {
            // Even line number: sentence
            if(lineNumber % 2 == 0)
            {
                sentences.Add(lineOfText);
            }
            // odd line number: clue
            else
            {
                clues.Add(lineOfText);
            }
            lineNumber++;
        }
        // Call Gather function
        SendMessage("Gather");
    }
开发者ID:Darrick2theend,项目名称:Lab04,代码行数:37,代码来源:LoadScript.cs

示例2: Start

    void Start()
    {
        #region File Load
        // Read in file information
        originalFile = new FileInfo(Application.dataPath + "/trivia.txt");
        if (!originalFile.Equals(null) && originalFile.Exists)
            reader = originalFile.OpenText();
        else
        {
            textFile = (TextAsset)Resources.Load("embeddedTrivia", typeof(TextAsset));
            reader = new StringReader(textFile.text);
        }

        #endregion

        #region File Read

        string lineOfText;
        int lineNumber = 0;

        // Determine where data should go based on
        //    Which line was read in
        while ((lineOfText = reader.ReadLine()) != null)
        {
            int lineNumberCheck = lineNumber % READIN_LINES;
            switch (lineNumberCheck)
            {
                case((int)ReadLineType.QUESTION): // Question line
                    numQuestions++;
                    questionsList.Add(lineOfText);
                    break;
                case((int)ReadLineType.ANSWERS): // Answers line
                    answersList.Add(lineOfText);
                    break;
                case((int)ReadLineType.CORRECT): // Correct answers line
                    correctList.Add(lineOfText);
                    break;
                default:
                    break;
            }
            lineNumber++;
        }
        #endregion

        #region Data Initialization
        // Initialize array sizes
        loadQuestions = new string[numQuestions];
        loadAnswers = new string[numQuestions, NUM_ANSWERS];
        loadCorrect = new string[numQuestions];

        // Load read data into the arrays
        for (int i = 0; i < numQuestions; i++)
        {
            loadQuestions[i] = questionsList[i];
            loadCorrect[i] = correctList[i];
            // Split the answers list apart
            string[] separateAnswers = new string[NUM_ANSWERS];
            separateAnswers = answersList[i].Split(',');
            // Load the answers as string arrays within the answers string array
            for (int j = 0; j < NUM_ANSWERS; j++)
            {
                loadAnswers[i, j] = separateAnswers[j];
            }
        }
        #endregion

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


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