Button--->中加入事件
FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); this.txtPath.Text = path.SelectedPath;
TextBox-->更改名稱 txtPath
測試環境 :c#
Button--->中加入事件
FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); this.txtPath.Text = path.SelectedPath;
TextBox-->更改名稱 txtPath
測試環境 :c#
CString FileName = L"C:\\123.txt";
int buf = 0;
buf = _waccess(FileName , 04);
if (buf != 0) { AfxMessageBox(L"Files error"); return false; }測試環境:MFC
// Example code
CFolderPickerDialog m_dlg;
CString m_Folder;
m_dlg.m_ofn.lpstrTitle = _T("Put your title here");
m_dlg.m_ofn.lpstrInitialDir = _T("C:\\");
if (m_dlg.DoModal() == IDOK) {
m_Folder = m_dlg.GetPathName(); // Use this to get the selected folder name
// after the dialog has closed
// May need to add a '\' for usage in GUI and for later file saving,
// as there is no '\' on the returned name
m_Folder += _T("\\");
UpdateData(FALSE); // To show updated folder in GUI
// Debug
TRACE("\n%S", m_Folder);
}
// End of example
測試環境:MFC
using System.IO;
取得程式當下檔案目錄資訊: string sPath = this.GetType().Assembly.Location;
string filename = @"C:\Users\123.text"; if (File.Exists(filename)) { MessageBox.Show("取得檔名(不包含附檔名)" + Path.GetFileNameWithoutExtension(filename)); MessageBox.Show("取得副檔名:" + Path.GetExtension(filename)); MessageBox.Show("目錄資料夾路徑:" + Path.GetDirectoryName(filename)); MessageBox.Show("資料根目錄:" + Path.GetPathRoot(filename)); MessageBox.Show("取得路徑:" + Path.GetFullPath(filename)); }
測試環境:c#.net 2015
建創一個元件TextBox 命名 tbox
using System.IO;
FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); this.tbox.Text = path.SelectedPath;
測試環境:VS2015 C#.NET
專案路徑↓
TCHAR path[MAX_PATH]; ::GetModuleFileName(NULL, path, _MAX_PATH);//獲取檔案路徑 PathRemoveFileSpec(path);//去除檔名
測試環境:VS2015 MFC
CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) CONVERT style參數說明 1 (expression為 money 或 smallmoney型別): 0 : 預設,保留小數位後兩位,並四捨...