「VC++.NET」の版間の差分
ナビゲーションに移動
検索に移動
(ページの作成:「==基本== ===ポインタ と new と null=== StreamWriter^ pwriter = nullptr; pwriter = gcnew StreamWriter("C:\\KBTest.txt"); ===ファイルの読み書き===…」) |
|||
| (同じ利用者による、間の1版が非表示) | |||
| 6行目: | 6行目: | ||
===ファイルの読み書き=== | ===ファイルの読み書き=== | ||
====ファイルを読む==== | ====ファイルを読む==== | ||
| − | listBox1- | + | listBox1->Items->Clear(); |
try { | try { | ||
String^ textFile = String::Concat(windir,"\\mytest.txt"); | String^ textFile = String::Concat(windir,"\\mytest.txt"); | ||
| − | + | Stream[[R]]eader^ reader = gcnew Stream[[R]]eader(textFile); | |
do | do | ||
{ | { | ||
| − | listBox1- | + | listBox1->Items->Add(reader->[[R]]eadLine()); |
} | } | ||
| − | while(reader- | + | while(reader->Peek() != -1); |
} | } | ||
catch(FileNotFoundException^ ex) | catch(FileNotFoundException^ ex) | ||
{ | { | ||
| − | listBox1- | + | listBox1->Items->Add(ex); |
} | } | ||
catch(System::Exception^ e) | catch(System::Exception^ e) | ||
{ | { | ||
| − | listBox1- | + | listBox1->Items->Add(e); |
} | } | ||
====ファイルに書く==== | ====ファイルに書く==== | ||
StreamWriter^ pwriter = gcnew StreamWriter("C:\\KBTest.txt"); | StreamWriter^ pwriter = gcnew StreamWriter("C:\\KBTest.txt"); | ||
| − | pwriter- | + | pwriter->WriteLine("File created using StreamWriter class."); |
| − | pwriter- | + | pwriter->Close(); |
| − | listBox1- | + | listBox1->Items->Clear(); |
String ^filew = gcnew String("File Written to C:\\KBTest.txt"); | String ^filew = gcnew String("File Written to C:\\KBTest.txt"); | ||
| − | listBox1- | + | listBox1->Items->Add(filew); |
====ファイル情報の表示==== | ====ファイル情報の表示==== | ||
| − | listBox1- | + | listBox1->Items->Clear(); |
String^ testfile = String::Concat(windir,"\\notepad.exe"); | String^ testfile = String::Concat(windir,"\\notepad.exe"); | ||
FileInfo^ pFileProps = gcnew FileInfo(testfile); | FileInfo^ pFileProps = gcnew FileInfo(testfile); | ||
| − | listBox1- | + | listBox1->Items->Add(String::Concat("File Name = ", pFileProps->FullName)); |
| − | listBox1- | + | listBox1->Items->Add(String::Concat("Creation Time = ", pFileProps->CreationTime.ToString())); |
| − | listBox1- | + | listBox1->Items->Add(String::Concat("Last [[Access]] Time = ", pFileProps->Last[[Access]]Time.ToString())); |
| − | listBox1- | + | listBox1->Items->Add(String::Concat("Last Write Time = ", pFileProps->LastWriteTime.ToString())); |
| − | listBox1- | + | listBox1->Items->Add(String::Concat("Size = ", pFileProps->Length.ToString())); |
| − | ===リンク=== | + | ===[[リンク]]=== |
*[http://msdn2.microsoft.com/ja-jp/library/ms306608.aspx クラスライブラリ ドキュメント] | *[http://msdn2.microsoft.com/ja-jp/library/ms306608.aspx クラスライブラリ ドキュメント] | ||
*[http://msdn2.microsoft.com/ja-jp/library/ms235289.aspx C++ マネージ拡張から Visual C++ 2005 に移行するためのガイド] | *[http://msdn2.microsoft.com/ja-jp/library/ms235289.aspx C++ マネージ拡張から Visual C++ 2005 に移行するためのガイド] | ||
| 53行目: | 53行目: | ||
*[http://forums.microsoft.com/MSDN-JA/ShowForum.aspx?ForumID=188&SiteID=7 Visual C++ Express Edition フォーラム] | *[http://forums.microsoft.com/MSDN-JA/ShowForum.aspx?ForumID=188&SiteID=7 Visual C++ Express Edition フォーラム] | ||
| − | ===VC++.NET Express=== | + | ===VC++[[.NET]] Express=== |
| − | *VC++.NET Express | + | *VC++[[.NET]] Express |
| − | *VC++.NET コードテンプレート | + | *VC++[[.NET]] コードテンプレート |
| − | *VC++.NET Express から | + | *VC++.NET Express から [[Oracle]]へ接続 |
| − | ===アルゴリズム=== | + | ===[[アルゴリズム]]=== |
| − | *アルゴリズム | + | *[[アルゴリズム]] |
| − | === | + | ===[[言語]]仕様=== |
*C++ CLI コードテンプレート 継承 | *C++ CLI コードテンプレート 継承 | ||
| − | ===Tips=== | + | ===[[Tips]]=== |
*[http://www.microsoft.com/japan/msdn/vstudio/express/visualc/usingpsdk/ Visual C++ 2005 Express Edition と Microsoft Platform SDK を一緒に使う] | *[http://www.microsoft.com/japan/msdn/vstudio/express/visualc/usingpsdk/ Visual C++ 2005 Express Edition と Microsoft Platform SDK を一緒に使う] | ||
*[http://www.cs.brown.edu/courses/cs123/javatoc.shtml Java to C++ Transition Tutorial] | *[http://www.cs.brown.edu/courses/cs123/javatoc.shtml Java to C++ Transition Tutorial] | ||
=====IDE===== | =====IDE===== | ||
| − | * VC++.NET イベントハンドラの追加 | + | * VC++[[.NET]] イベントハンドラの追加 |
| − | * VC++.NET ToolStripの作成 | + | * VC++[[.NET]] ToolStripの作成 |
2020年2月16日 (日) 04:33時点における最新版
目次
基本
ポインタ と 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
アルゴリズム
言語仕様
- C++ CLI コードテンプレート 継承
Tips
IDE
© 2006 矢木浩人