请问一下C#
来源:百度知道 编辑:UC知道 时间:2024/05/14 03:32:58
请问一下:
如下代码,是为了从文本文件中读取数据
可是最终结果是 能够确定X盘符里有某文件,确不能读出里面的数据!请问这是为什么?!帮我看看,谢谢!~~ 代码如下:
----------------------------------------
using System;
using System.IO;
using System.Text;
namespace FilesRead
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
FileStream fs;
string path;
Console.WriteLine("输入要读取的文件之文件名:");
path=Console.ReadLine();
try
{
if(!File.Exists(path))
{
Console.WriteLine("文件不存在!");
}
else
{
fs=File.OpenRead(path);
Console.WriteLine("文件存在!!");
}
return;
byte[] arr=new byte[100];
UTF8Encoding data=new UTF8Encoding(true);
如下代码,是为了从文本文件中读取数据
可是最终结果是 能够确定X盘符里有某文件,确不能读出里面的数据!请问这是为什么?!帮我看看,谢谢!~~ 代码如下:
----------------------------------------
using System;
using System.IO;
using System.Text;
namespace FilesRead
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
FileStream fs;
string path;
Console.WriteLine("输入要读取的文件之文件名:");
path=Console.ReadLine();
try
{
if(!File.Exists(path))
{
Console.WriteLine("文件不存在!");
}
else
{
fs=File.OpenRead(path);
Console.WriteLine("文件存在!!");
}
return;
byte[] arr=new byte[100];
UTF8Encoding data=new UTF8Encoding(true);
using System;
using System.IO;
using System.Text;
namespace FilesRead
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
public static FileStream fs;
[STAThread]
static void Main(string[] args)
{