| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

VC++.NET

提供: MyMemoWiki
2020年2月15日 (土) 07:36時点におけるPiroto (トーク | 投稿記録)による版 (ページの作成:「==基本== ===ポインタ と new と null=== StreamWriter^ pwriter = nullptr; pwriter = gcnew StreamWriter("C:\\KBTest.txt"); ===ファイルの読み書き===…」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

基本

ポインタ と new と null

StreamWriter^ pwriter = nullptr;
pwriter = gcnew StreamWriter("C:\\KBTest.txt");

ファイルの読み書き

ファイルを読む

listBox1->Items->Clear();
try {
    String^ textFile = String::Concat(windir,"\\mytest.txt");
    StreamReader^ reader = gcnew StreamReader(textFile);
    do
    {
        listBox1->Items->Add(reader->ReadLine());
    }
    while(reader->Peek() != -1);
}
catch(FileNotFoundException^ ex)
{
    listBox1->Items->Add(ex);
}
catch(System::Exception^ e)
{
    listBox1->Items->Add(e);
}

ファイルに書く

StreamWriter^ pwriter = gcnew StreamWriter("C:\\KBTest.txt");
pwriter->WriteLine("File created using StreamWriter class.");
pwriter->Close();
listBox1->Items->Clear();
String ^filew = gcnew String("File Written to C:\\KBTest.txt");
listBox1->Items->Add(filew);

ファイル情報の表示

listBox1->Items->Clear();
String^ testfile = String::Concat(windir,"\\notepad.exe");
FileInfo^ pFileProps = gcnew FileInfo(testfile);

listBox1->Items->Add(String::Concat("File Name = ", pFileProps->FullName));
listBox1->Items->Add(String::Concat("Creation Time = ", pFileProps->CreationTime.ToString()));
listBox1->Items->Add(String::Concat("Last Access Time = ", pFileProps->LastAccessTime.ToString()));
listBox1->Items->Add(String::Concat("Last Write Time = ", pFileProps->LastWriteTime.ToString()));
listBox1->Items->Add(String::Concat("Size = ", pFileProps->Length.ToString()));


リンク

VC++.NET Express

  • VC++.NET Express
  • VC++.NET コードテンプレート
  • VC++.NET Express から Oracleへ接続

アルゴリズム

  • アルゴリズム

言語仕様

  • C++ CLI コードテンプレート 継承

Tips

IDE
  • VC++.NET イベントハンドラの追加
  • VC++.NET ToolStripの作成