Browse c:C#-浏览文件夹和二进制阅读器(binary reader)

我很难让 Binary Reader 检测从“浏览文件夹”对话框中选择的文件。目的是在目录中的所有文件中的“X”位置读取并将该数据保存到 TXT 文件。我尝试了各种方法,但似乎无法得到它...

BinaryReader NDSRead2 = new BinaryReader(file)

我放入替换(file)的任何内容都会抛出错误。尝试了与该行和其他地方在我的代码中的各种方式,但似乎无法得到它。我的代码被列出打击

 /// OPEN FOLDER DIALOGUE      
        FolderBrowserDialog fbd = new FolderBrowserDialog();
        fbd.Description = "Select a folder";
        fbd.ShowNewFolderButton = false;
        if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
           /// THIS NEXT CHUNK OF CODE SETS UP WHERE THE TXT FILE WILL BE SED, IN THE SELECTED DIRECTORY.
            string brlTextLoc = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            DirectoryInfo dir1 = new DirectoryInfo(fbd.SelectedPath);
           txtBRLSave = new System.IO.StreamWriter(fbd.SelectedPath + "BuildRomList.TXT", true);
            txtBRLSave.WriteLine("Build Rom List");
            txtBRLSave.WriteLine("Using The Rom Assistant v0.57");
            txtBRLSave.WriteLine();
          /// THE LOOP FOR EACH FILE TO BE READ IN FOLDER BEGINS.
            FileInfo[] files = dir1.GetFiles();
            System.IO.StreamWriter txtBRLSave;
            foreach (string file in Directory.EnumerateFiles(fbd.SelectedPath, "*.EXT"))
            {
                BinaryReader NDSRead2 = new BinaryReader(file);
            /// THE ISSUE I HE IS WITH "(FILE)" ABOVE... IT KEEPS GETTING FLAGGED IN RED NO MATTER WHAT I PUT IN THERE.
           /// BELOW CONTINUES THE BR CODE, AND TXT SING CODE, WHICH ISN'T NEEDED FOR THIS QUESTION AS I KNOW IT WORKS.
2

将字符串传递到流中,如下所示

foreach(string file in Directory.EnumerateFiles(...
{
    using(var stream = new FileStream(file, FileMode.Open))
    using(var NDSRead2 = new BinaryReader(stream))
    {
       // do you stuff
    }
}

本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处

(321)
Condom fish:鱼壳提示:鱼不读鱼_prompt.fishnorfish_right_prompt.fish
上一篇
Linux递归创建目录命令:递归计数 Linux目录中的文件(linux count files in directory re
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(76条)