private void chooseToolStripMenuItem_Click(object sender, EventArgs e) { using (BrowseForFolder dialog = new BrowseForFolder()) { if (dialog.ShowDialog() == DialogResult.OK) { explorerBrowser1.FolderIdList = dialog.SelectedFolderIdList; } } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { var fbd = new BrowseForFolder(); var hwnd = new WindowInteropHelper(this).Handle; string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string path = fbd.SelectFolder("Select a folder containing one or more game files.", docPath, hwnd); if (!string.IsNullOrWhiteSpace(path)) { AddDirectory(path); } }
private void btnAnalysisFolder_Click(object sender, EventArgs e) { BrowseForFolder bff = new BrowseForFolder(); bff.Filters.Add("zip"); bff.Filters.Add("trc"); bff.Filters.Add("blg"); bff.Filters.Add("mdf"); bff.Filters.Add("ini"); bff.Filters.Add("etl"); bff.Filters.Add("evtx"); bff.Filters.Add("mdmp"); string strPath = Environment.CurrentDirectory as string; strPath = bff.SelectFolder("Choose an SSASDiag folder or zip file for analysis of all its components.\r\nOR\r\n" + "AS profiler trace file or db, PerfMon log, crash dump, network trace, or config file.", txtFolderZipForAnalysis.Text == "" ? strPath : txtFolderZipForAnalysis.Text, Handle); if (strPath != null && strPath != "") { txtFolderZipForAnalysis.Text = m_analysisPath = strPath; LogFeatureUse("Analysis File Opened", strPath.Substring(strPath.LastIndexOf("\\") + 1)); PopulateAnalysisTabs(); } AnalysisMessagePumpTimer.Interval = 1000; }
public static string OpenFolderDialog(string initPath, string dialogTitle = "选择文件夹") { return(BrowseForFolder.SelectFolder(dialogTitle, initPath, IntPtr.Zero)); }
void Start() { browser = new BrowseForFolder(); handle = GetForegroundWindow(); initialPath = @"C:\Users\oguz\Desktop\"; //#if UNITY_EDITOR //int fWidth = Screen.width; //int fHeight = Screen.height; //MoveWindow( handle , 2000 , 0 , fWidth , fHeight , 1 ); // move the Unity Projet windows >>> 2000,0 Secondary monitor ;) //ShowWindowAsync( handle , 3 ); // full screen // SW_SHOWMAXIMIZED ////MessageBox( handle , "Hello From Windows Api" , "Title Goes Here" , 0x00000010L ); //var info = new _browseinfoW(); //info.hwnd = handle; //info.root = IntPtr.Zero; ////info.root = Application.dataPath; //info.displayName = "Select Folder"; //info.callback = new BrowseCallbackProc( OnBrowseCallbackProc ); //info.flags = 0x00000040; //info.lParam = IntPtr.Zero; //info.image = 0; //StringBuilder sb = new StringBuilder( 256 ); //IntPtr bufferAddress = Marshal.AllocHGlobal( 256 ); ; //var pointer = SHBrowseForFolderW( ref info ); //if ( SHGetPathFromIDList( pointer , bufferAddress ) ) //{ // sb.Append( Marshal.PtrToStringAuto( pointer ) ); //} //Debug.Log( sb.ToString() ); //OpenFileName ofn = new OpenFileName(); //ofn.structSize = Marshal.SizeOf( ofn ); //ofn.filter = "Image Files\0*.jpg\0Batch files\0*.bat\0"; //ofn.file = new String( new char [ 256 ] ); //ofn.maxFile = ofn.file.Length; //ofn.fileTitle = new String( new char [ 64 ] ); //ofn.maxFileTitle = ofn.fileTitle.Length; //ofn.initialDir = "C:\\"; //ofn.title = "Open file called using platform invoke..."; //ofn.defExt = "txt"; //ofn.flags = 0x00000200 | 0x00000001; //var dialog = new OpenFileDialog(); //dialog.Multiselect = true; //dialog.ShowDialog(); // const string message = //"Are you sure that you would like to close the form?"; // const string caption = "Form Closing"; // var result = System.Windows.Forms.MessageBox.Show( message , caption , // MessageBoxButtons.YesNo , // MessageBoxIcon.Question ); //if ( GetOpenFileName( ofn ) ) //{ // Debug.LogFormat( "Selected file with full path: {0}" , ofn.file ); // Debug.LogFormat( "Selected file name: {0}" , ofn.fileTitle ); // Debug.LogFormat( "Offset from file name: {0}" , ofn.fileOffset ); // Debug.LogFormat( "Offset from file extension: {0}" , ofn.fileExtension ); //} }