Freek's Blog

SQL en .NET vraagstukken en oplossingen die ik zoal tegenkom
posts - 199, comments - 123, trackbacks - 2, articles - 7

My Links

News

Google analytics script: Locations of visitors to this page

Article Categories

Archives

Post Categories

Image Galleries

Algemene links

MSDN

vb links

Tuesday, May 04, 2010

 

//write value to given file
//value is the text to write
//path is the location of the text file

        public void funcWriter(string value, string path)

        {

 

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path, true))

            {

                sw.WriteLine(value);

                sw.Flush();

            }

 

        }

 

posted @ 3:56 PM | Feedback (0)

 

            //read all files in directory and store them

            string[] array1 = System.IO.Directory.GetFiles(lblPath.Text);

 

            //process each file

            foreach (string s in array1)

            {

                //do something

            }

 

posted @ 3:54 PM | Feedback (0)

using System;
using System.IO;

 

      private void button1_Click(object sender, EventArgs e)

        {

 

            string path = @"c:\temp\MyTest.txt";

 

 

            try

            {

                using ( System.IO.StreamReader sr = new System.IO.StreamReader(path))

                {

                    while (sr.Peek() >= 0)

                    {

                        Console.WriteLine(sr.ReadLine());

                    }

                }

 

 

            }

            catch (Exception)

            {

 

                Console.WriteLine("The process failed: {0}", e.ToString());

 

            }

           

        }

 

posted @ 10:02 AM | Feedback (0)

       private void btnDirectory_Click(object sender, EventArgs e)

        {

 

            FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();

            string folderName="";

 

          DialogResult result =  folderBrowserDialog1.ShowDialog();

 

            if (result == DialogResult.OK)

            {

                folderName = folderBrowserDialog1.SelectedPath;

            }

 

 

            Console.WriteLine("Selected path: {0}",folderName);

 

           

        }

 

 

posted @ 9:48 AM | Feedback (0)

posted @ 8:45 AM | Feedback (0)