如何在C++/CLI中返回到文件开头?

问题描述 投票:0回答:1

不知道怎么回到文件开头

在 C++ 中,我可以关闭然后再次打开文件。

但是没有“read_file->Open()”

StreamReader^ read_file = gcnew StreamReader(path + "\\" + file);
//CODE
read_file->Close();
//And now what to open it again or go to begining?

我没有尝试任何东西,因为我只是不知道。

c++-cli
1个回答
0
投票

只需创建一个新的

StreamReader
,即

auto read_file = gcnew StreamReader(path + "\\" + file);
auto line = read_file->ReadLine();
read_file->Close();
//re-open
read_file = gcnew StreamReader(path + "\\" + file);
© www.soinside.com 2019 - 2024. All rights reserved.