1

This is a pretty simple and easy question: How do I store and use file inside User's AppData directory?

I'm making a simple multimedia player and I want to store my library.xml file somewhere on the user's computer.

I'd also like to know how to use them, for example if I want to use my library.xml file with FileStream how do I make a reference to it?

ReadFileStream = new FileStream(@"\WHERE-IS-IT\Library.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Tommy B.
  • 3,591
  • 14
  • 61
  • 105

2 Answers2

4
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Take a look at this previous answer: C# getting the path of %AppData%

Community
  • 1
  • 1
Justin Morgan
  • 2,427
  • 2
  • 16
  • 19
  • Thanks for this answer, it helps a lot! Is there any MSDN page about how to store settings file, etc? Do I have to create a directory and the files on the first start of the application? Thanks again. – Tommy B. Feb 08 '11 at 03:14
  • You should definitely create your own directory... usually the convention is `(AppData)/Company/Product/`. What you do in there is totally up to you. – Justin Morgan Feb 08 '11 at 03:16
2

Take a look at the isolated storage in .NET. It takes care of the location and security per windows flavour. isolatedstoragefile can be used to manange files and directories. isolatedstoragefilestream can be used to access files.

Mubashir Khan
  • 1,464
  • 1
  • 12
  • 17