本文整理汇总了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");
}
示例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");
}