OpenFileDialog in VB.NET

OpenFileDialog

इसका प्रयोग open file dialog box को display करने के लिए किया जाता है। यह dialog box user को file select और open करने की सुविधा प्रदान करता है। यह user को multiple files select करने की सुविधा देता है। इसमे files और folders की list display होती है। जिसमे से user files को select कर सकता है और उन्हे process कर सकता है। इसे display करने के लिए ShowDialog() method का use किया जाता है। यह एक वैल्यू return करती है जो की dialog मे click की गई button को बताती है।

If OpenFileDialog1.ShowDialog = DialogResult.OK Then
MsgBox (OpenFileDialog1.FileName)
End If

Related image

Properties of OpenFileDialog

  • Name: इसका use control का name define किया जाता है। जो dialog को codes मे identify करता है।
  • AddExtension: यह property determine करती है की dialogbox FileName मे automatically extension add कर लेगा या नहीं यदि use उसे मिटा देता है।
  • CheckFileExists: इसके true होने पर DialogBox automatically input किए गए file name को check कर लेगा। file के exist नहीं होने पर यह warning message display करता है।
  • CheckPathExists: इसके True होने पर dialogbox File के path को automatically check कर लेगा। Path exist नहीं होने पर यह warning message display करता है।
  • DefaultExe: इसका use Default filename extension set करने के लिए किया जाता है। जो की extension नहीं देने पर भी file के साथ automatically add हो जाता है।
  • FileName: इसका use Dialog box मे select की गई file को और उसके path को get करने के लिए किया जाता है। यह Selected File Name को return करती है।
  • FileNames: यह property multiple files को select करने पर सभी files को उनके path के साथ get करने के लिए किया जाता है।
  • Filter: यह openfiledialog box की एक important property है। इसका use Files को filter करने के लिए किया जाता है। यह dialog मे display होने वाली files के type कोspecify करने के लिए किया जाता है। जैसे Text files को display करने के लिए Filter मे “Text Files|*.txt” set करते है। Pipeline ( | ) character का use file description और Extension को अलग अलग करने के लिए किया जाता है। यह एक साथ कई file extension set करने के लिए semicolor character का use किया जाता है। जैसे – “BMP,GIF and JPG|*.bmp;*.gif;*.jpg”
  • FilterIndex: इसका use Filter property मे define किए गए Filters मे default filter को set करने के लिए किया जाता है। यह interger type की वैल्यू contain करती है।
  • InitialDirectory: इसका use dialog box के लिए initial directory set करने के लिए किया जाता है। जो default open होती है।
  • MultiSelect: इसके true होने पर Dialog box मे multiple files को select किया जा सकता है।
  • RestoreDirectory: इसे true करने पर dialog box previous मे open की गई directory को automatically save कर लेता है और दुबारा open करने पर वही directory open हो जाती है।
  • ShowHelp: इसके true होने पर Help button display होती है।
  • Title: यह property dialog box के title को set करने के लिए किया जाता है।
  • ShowReadOnly: इसके true होने पर ReadOnly का एक checkbox भी openfiledialog मे display होता है।

error: Content is protected !!