Mar 21, 2014

How to implement Folder Browser Dialogbox (FolderBrowserDialog) in c#

C# Code:

string folder=””;
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
    dialog.Description = "Open a folder which contains your files”;
    dialog.ShowNewFolderButton = false;
    dialog.RootFolder = Environment.SpecialFolder.MyComputer;
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        folder = dialog.SelectedPath;
 
    }

}

How to implement open filedialogbox in c#

C# Code:

String ImagePath=””;
OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
OpenFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
OpenFileDialog1.Filter = "(*.png)|*.png|All Files (*.*)|*.*";
OpenFileDialog1.FilterIndex = 1;

if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
{
    ImagePath= OpenFileDialog1.FileName;

}

How to get Filename with extension from path in c#

C# Code:

string FilePath ="D:\\images\\1.png";

string Extention = Path.GetFileName(FilePath);

How to get only File extension from path in c#

C# Code:

string FilePath ="D:\\images\\1.png";

string Extention = Path.GetExtension(FilePath);

How to get Filename without extension from path in c#

C # Code:

string FilePath ="D:\\images\\1.png";

string Filename = Path.GetFileNameWithoutExtension(FilePath);

How to resizeImage and save using c#.Net

C# Code:

private Bitmap SetResizeImage(string strImg, string FileName, int Imagewidth, int ImageHeight)
{
    int nnx = Imagewidth;
    int nny = ImageHeight;
    System.Drawing.Image img = System.Drawing.Image.FromFile(strImg);
    Bitmap cpy = null;
    cpy = new Bitmap(nnx, nny);
    using (Graphics gr = Graphics.FromImage(cpy))
    {
        gr.Clear(Color.Transparent);
        gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
        gr.DrawImage(img, new Rectangle(0, 0, nnx, nny), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
    }
   return cpy;

}
------------------------------------------------------------------------------------------------------------

Mar 19, 2014

How to insert a list (Data) in google spreadsheet in c# ?

Before coding, create uri for your spreadsheet, see below setpes:
1.login to google drive and open your spreadsheet
2.Download spreadsheet through (File -> Dowanload as -> Webpage) then new page will be oped