GST Billing Software

header image

Use browse file, open file, save file without the help of Kushal

Erachana Line

68. How to use browse file, open file, save file without the help of Kushal?

In Kushal we have a provision to run C# code, when we need to use other than common dlls, we don't have a provision to write header files on Kushal Expressions. To achieve that, we can directly write code using namespaces of the header files. (Ex: Code like OpenFileDialog, ShowFileDialog etc)

OpenFileDialog


OpenFileDialog fdlg = new OpenFileDialog();

fdlg.Title = "Attachments";

if(fdlg.ShowDialog() == DialogResult.OK)

{

this.sFile_Path = fdlg.FileName;

this.sFile_Name = System.IO.Path.GetFileName(fdlg.FileName);

txt_FilePath.Text = fdlg.FileName.ToString();

}

SaveFileDialog


SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = @"C:\";
saveFileDialog1.Title = "Save text Files";
saveFileDialog1.CheckFileExists = true;

if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = saveFileDialog1.FileName;
}

FolderBrowserDialog


FolderBrowserDialog folderDlg = new FolderBrowserDialog();
folderDlg.ShowNewFolderButton = true;
// Show the FolderBrowserDialog.
DialogResult result = folderDlg.ShowDialog();
if (result == DialogResult.OK)
{
textBox1.Text = folderDlg.SelectedPath;
Environment.SpecialFolder root = folderDlg.RootFolder;
}