Creating a text file on click of a button
<p>I basically want to create a text file that will have contents that will be fetched from one of the tables in my Database. The contents should display as follows:-</p>

<pre><code>Item1 ID1
Item2 ID2
Item3 ID3
Item4 ID4
Item5 ID5
</code></pre>

<p>I want the contents exactly like this. The names of the items and IDs will be diff ofcourse but the way of them appearing in th etext file should be like this.</p>

<p>How do I go about this? Please give me some ideas. I tried to create a file using the following code:-</p>

<pre><code>  using (var sw = new StreamWriter(File.Open(@"D:\myFile.txt", FileMode.CreateNew), Encoding.GetEncoding("iso-8859-1")))
            {
        sw.WriteLine("my text...");                         
            }
</code></pre>

<p>and it got created fine. BUT, when I tried to create a file in C: drive, it said access to path denied. I basically want to create a map file in helicon which is installed in c:
Also once the file has been created, then again when I click a "Create File" button in my c# code, it should either delete the file and create it again or overwrite its contents with the fresh data from my Items Table. What should I do?
Please help me! I am new to all this. How do I make it work ? </p>
