CsvWriter Path Error Message

Dec 10, 2012 at 2:22 PM

Hi there

Just trying out CsvWriter for the first time.  I copied your example code (C#) but I'm getting the following runtime error...

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Temp\data.csv'

I think it should create that file?  The folder C:\Temp exists.  As a long-shot, I tried creating an empty data.csv file in there, just in case, but that makes no difference.

Any ideas what I'm doing wrong?

Thanks and regards

Jeff


Coordinator
Dec 11, 2012 at 12:07 PM

Hi Jeff,

Perhaps your user does not have write access for that folder? Please try modifying the path to write somewhere you know you have access to, such as your user directory. Let me know how it goes.

Best,
Kent 

Dec 11, 2012 at 4:00 PM

Hi Kent

Thanks for the speedy response.  

Yes, I've tried different folders, all of which my user ID can read/write to.  I can certainly create the CSV file manually via Windows Explorer,  I'm guessing the problem is something to do with the fact that it's an online process that's trying to do the writing in this case?  This is new territory for me, but I imagine that there must be security in place to prevent online processes from writing stuff just anywhere on my hard drive?  

But, if so, I have no idea how to go about granting that authority.

Kind regards

Jeff

Coordinator
Dec 11, 2012 at 5:16 PM

Hi Jeff,

Yes, that would be it. What kind of online process is it? Silverlight? XBAP? ClickOnce?

Each of these have differing security models, but all sandbox the application to one extent or another. You would need to read up on the specifics of the particular technology you've used in order to determine how restrictive it is and what options you have to move forward. In Silverlight, for example, I believe you can prompt the user for a location to write to.

HTH,
Kent 

Dec 11, 2012 at 7:20 PM

Wow Kent, you really *are* super fast today!  :o)

I'm just using WebMatrix to create a couple of simple CSHTML pages and wanted to see if was possible to export data from the underlying SQLCE database into a CSV for download to the local PC.

Thanks for your insight, based on that I am researching and hope not to have to ask any further...

Kind regards

Jeff