Creating file in vs 13 for windows app

I want to create a csv file in the root folder for my app. The file should be created only if it doesn't exist, if it exists it should just add data in new line in the same file.

You can't rely on creating files where your programme is installed.
Most users will not have create permission nowadays.
You can easily prove this yourself.
Open file explorer.
navigate to a folder under programs where you have something installed.
Right click on an empty bit and choose New on the menu.
On my win8.1 machine I see Folder as the only option.
They changed this since I think Win7 but maybe also Vista. 
You should use AppData.
This helper gets you the location of Appdata on the machine and adds your programme's namespace for a folder within that:
public static class AppData
public static string Location = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData), System.Reflection.Assembly.GetExecutingAssembly().EntryPoint.DeclaringType.Namespace);
This code here is serialising an object to FontDetails.xml in such a folder:
private void Application_Exit(object sender, ExitEventArgs e)
var fileName = Path.Combine(AppData.Location, "FontDetails.xml");
if (!Directory.Exists(AppData.Location))
Directory.CreateDirectory(AppData.Location);
FontDetails fd = Application.Current.Resources["FontDetails"] as FontDetails;
DataContractSerializer ser = new DataContractSerializer(typeof(FontDetails));
var xmlSettings = new XmlWriterSettings { Indent = true, IndentChars = "\t" };
using (var writer = XmlWriter.Create(fileName, xmlSettings))
ser.WriteObject(writer, fd);
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles

Similar Messages

  • Trying to install Acrobate 8 Standard on PC with Windows 7, 64 bit. During the installation I was asked to provide "File Adobe PDF.dll for Windows Vista. How can I obtain the required file?

    Trying to install Acrobate 8 Standard on PC with Windows 7, 64 bit. During the installation I was asked to provide "File Adobe PDF.dll for Windows Vista. How can I obtain the required file?

    Nothing in the Acrobat 8.x product family is compatible with Windows 7 (or any contemporary OS).
    The Acrobat 8.x product family passed into End of Support way back -- (November 2011).
    The current release of Acrobat (XI) is compatible in Windows 7.
    Be well...

  • Adobe Create Suite 4 Design Premium for Windows Lost Application disk #2

    Hi, I have the Adobe Create Suite 4 Design Premium for Windows and have lost the Application disk #2 and cannot reinstall this on my new laptop.  I have the licenses and the rest of the disks.  I have called Adobe and they no longer support CS4.  They suggested I try to find someone who has the software and get a copy of disk 2

    I'm not seeing anything but individual applications (and it looks like updates, not installers) in the public forders.
    You should be able to get the trial by going to Download Adobe CS4 and CS3 Free Trials Here (incl. After Effects) | ProDesignTools and following the directions VERY CAREFULLY. There is no differnce between trial and licensed installers, so you can enter your serial number when asked.
    If that doesn't work, send me a Private Message (click my name to go to my profile and see the actions list on the right) and I'll see what else I might be able to do for you.

  • Lost Adobe Create Suite 4 Design Premium for Windows disk #2

    Hi, I have the Adobe Create Suite 4 Design Premium for Windows and have lost the Application disk #2 and cannot reinstall this on my new laptop.  I have the licenses and the rest of the disks.  I have called Adobe and they no longer support CS4.  They suggested I try to find someone who has the software and get a copy of disk 2. Can some please help,  I don't want to upgrade to CS5

    >suggested I try to find someone who has the software and get a copy of disk 2
    I am surprised by that... my understanding (albeit poor) of copyright is that you are allowed to make a copy of a disc for your own personal backup storage
    That does not include making a copy to give to anyone else
    Old or Used Software http://www.emsps.com/oldtools/ Or http://www.retrosoftware.com/
    http://forums.adobe.com/message/1636890 warns about buying from eBay

  • I am confused by the installation step that requires you to create a bootable USB drive for windows installation.  What is the ISO image and why has it selected my Passport backup drive as the destination disc?

    In the bootcamp installation it asks me to create a bootable USB drive for Windows Installation.  To do so, I must choose an ISO image.  What is that?  When I click "choose" I don't understand the options presented.  Is this the destination of the partition or where Windows will reside on the Mac?  Why does it also indicate the the destination disk si my WD Passport Back up drive?

    OK, so I have an apple superdrive hooked up to my mini (along with my Passport back up drive).  I also have  the discs for both 64bit and 32bit Windows along with the product key.  I am still not sure what to do when faced with the options after "choose".

  • Disabling Automatic "Safe File" Opening in Safari for Windows

    I need 2 know how to *+Disabling Automatic "Safe File+"* Opening in Safari for windows.
    In options/general tab i don´t have the option that safari for mac have to disable it!

    Those pictures are .jpg images; the downloading is a function of the way they've constructed the links to them on the web site. But no file is being opened. The opening of "safe" files after downloading refers to files that are compressed or executable, and .jpg are not that.
    Aside from that, this appears to be a function that has been removed from Safari for Windows, so no files will open after downloading, regardless of whether or not they're "safe".
    Mulder

  • Use MacMini server for windows apps and save for windows files ?

    My question : Office equiped mixed computers , aslo Windows and Mac,
    Could we use MacMini server for both machines, working by windows apps and / or to save and work with windows files on MacMini server  and with Mac as well?
    We woud use it for normal office work and get it by internet from other places as well
    windows apps: merchandising, invoice, word, excel, pictures editing, Outlook Express + the Mac apps
    thnx ,
    MACIren

    In general what you can do is: in OS X, use Windows in virtualization (aka emulation), as a "virtual machine" with VMWare Fusion, Parallels, or Oracle VM Virtual box.
    That way you have both operating system open side by side without having to reboot into one or the other operating system.
    Not sure whether you need a Mac Mini Server per se to do that, I do that with my MacBook Pro for instance. But the server would help since it has a quad-core CPU (more cores that you can dedicate to the virtual macine), and you can put the virtual machine on the second harddrive for better disk access performance. Was there some particular reason you were thinking of the Mini Server -- do you want to use server side Windows apps?
    Again I have that setup on my MacBook Pro using VMWare Fusion with an XP virtual machine. In the Windows, I only use Office 2003 and some company apps that are Windows only. With Fusion (and I'm sure the other apps can do it as well) you can set a "shared" folder so both Windows and Lion will see the contents of it for reading and writing. I believe with Fusion you can also do your entire Home directory, but I prefer to limit it to a single shared "work" folder.

  • Problems with creating a USB boot device for Windows 8.1

    My iMac (late 2012) running OSX Mavericks is encountering problems creating a Windows 8.1 install disk via a USB thumbdrive. The drive has 8gb of space available, which is enough to fit windows. But when I choose my ISO image and select the drive I recieve an error message. The error is 'Bootcamp only supports 64-bit Windows installation on this platform. Please use a ISO file for 64-bit Windows installation.
    I'm certain this ISO definately contains 64-bit, so I'm slightly confused.
    I've followed instructions found in other discussions talking about adding an extra line of information to 'info.plist' found inside the Package Contents for bootcamp, but that has also not worked. If I try that, Bootcamp crashes upon being clicked every time.
    Any help is appreciated

    First up: a question. How did you fix the crashing Bootcamp Utility? It would help out this guy: https://discussions.apple.com/message/23523783?ac_cid=tw123456#23523783
    Next up: A possible solution (also posted here:https://discussions.apple.com/message/23523783?ac_cid=tw123456#23523783)
    =====================
    It's possible you have a Windows ISO for both 32- and 64-bit. In this case it's probably detecting the presence of the 32-bit installer and forgets to look for another 64-bit version.
    A way to work around this is to not use the Bootcamp Assistant utility by following the listed steps:
    The way installing Windows should work either way using the Legacy BIOS mode:
    - Get a Windows ISO or DVD and copy the contents over to a freshly fat32 formatted USB stick of at least 4GB.
    - Download the Apple Bootcamp Support Software (4.x or 5.x, 5.x only supports 64-bit, get that if you are going 64-bit);
    - Copy the content of the Support Software folder over the the same USB stick from the first step. It should fit just right (it did on my 4GB stick with 2MB te spare!);
    - Use disk utility to partition your disk. Make sure the partition for Windows is Fat32 and at least 30GB;
    - Reboot your machine while holding Option/Alt at the chime;
    - You should be able to select either your OSX HDD or your USB stick labeled "Windows" -> Select Windows and press enter or click the arrow;
    - The Windows installer should now load, format the previously made Windows partition to NTFS;
    - Continue on your way.
    Can you try what I typed above? If it doesn't work, can you let me know at what step things go differently than described?
    Edit: This is based on the logical conclusion that any Mac that was shipped without ODD should be able to boot from USB.
    Edit2:
    One other note is that Mac's have trouble booting from USB when multiple USB storage devices are attached. So make sure you connect only one storage device.
    =====================
    Best of luck to you!

  • Acrobat XI Pro for OSX can't open password-protected pdfs created using Acrobat 9 Pro for Windows

    I am having problems opening password-protected files created on a PC using Acrobat 9 Pro.  I am running a MacBook Pro OSX 10.8.4 with Acrobat XI Pro.  When I attempt to enter the password when prompted, a dialogue box pops up saying that I've entered the incorrect password.  After many attempts, I am certain that the password entered is correct -- this is reinforced by the fact that i am able to open the same document using Mac's Preview software.
    Any assistance would be appreciated!
    Thanks.

    I was suddenly having the same problem in Acrobat XI Pro for Windows (recently upgraded to CC from Acrobat X).  For the past while I've sometimes had to use the "insert from file" tool to get a page added from another file.  I couldn't figure out why dragging sometimes would no longer work, but was too busy to go looking for a solution until tonight. 
    The solution was given by JoshTatum24 above. Switch from a scrolling page display to single page display.  Now I can drag pages between documents again.  THANK YOU Josh!
    Oh, and CORREAdmin,  it does not matter whether the hand or arrow selection tool is active, my mouse pointer is always an arrow when positioned in the page thumbnails panel.  Switching selection tools does not make a difference in dragging, but switching between scrolling and single page display definitely DOES make the difference.

  • Windows Pro upgrade with Hyper-V for Windows App development

    Hi
    I am just starting to develop my first windows phone app. I dowloaded Visual studio 2013 express on my windows 8 machine. I started to follow the Microsoft Virtual Academy, Develop Windows phone apps for Beginners with Bob Tabor.
    Anyway, when i try to run the Emulator, it tells me i need Hyper-V which my version of windows doesn't have. Apparently i need Windows Professional. Anyway, this costs about £100 to upgrade. Also, for the emulator i am told i need 4gb of RAM.
    Question 1: My laptop is an i5, 64bit machine, windows 8.1 normal edition, with 4gb of RAM. It says of which 3.88gb of ram is usable. Whatever that means?
    The minimum requirement for the emulator is 4gb, will it work on my machine which apparently has 3.88 ?
    Question 2: I already own a nokia windows 8.1 phone. A basic enough model. Instead of buying the upgrade for windows pro, is it a big hassle to run my test apps on that phone? How difficult is it to run a test build of an app on my phone? Can i run it via
    the inside of visual studio? Or do i need to go to file explorer, copy and paste files over to the phone, disconnect it from the laptop etc. How many steps are involved? If its a load of hassle i might be safer to just bite the bullet and buy the Windows pro
    upgrade.
    (although i am aware the emulator can't test some things that the actual phone can..eg near field communication etc.)
    Any advice?
    Regards
    Conor

    It's not that big of a hassle to debug your app by deploying it on your phone. It's just a matter of choosing Device instead of Emulator when you start debugging in VS.
    Some of the downsides are that your phone's screen must be on and not showing the lock screen, and the fact that you can only have a maximum of 2 apps installed on your phone for debugging purposes. If you start developing and debugging a third app, then
    you must first uninstall one of the other 2 apps to be able to deploy the third app to your phone. To my knowledge the emulator does not have such a limit. I believe there's a paid developer account option available somewhere if you want to raise the limit
    beyond 2 apps.
    Other than that, being tied to a single resolution as Dave mentioned is another downside to using a device.

  • Jabber 10.5 for Windows + App Dial Rules + Phone Control Mode

    I am using all 10.5. 
    I have Jabber for Windows integrated with Outlook.  I have Application Dial Rules set up to handle converting numbers to what I need by stripping, adding 9s, adding 1s, etc.  It all works great when I'm using Jabber as a soft phone. 
    My problem is that almost nobody in the company has a PC camera/mic/speakers.  So all of the Jabber clients will be in phone control mode.  Because the call originates from the phone and not from an application, the Application Dial Rules get bypassed.  I understand why this is happening but I'm hoping there is a way around it.  Is there some setting that tells CUCM to notice that there was a CTI call to the phone from an application requesting that it make the call or something like that where CUCM realizes that the request "initially" came from a Jabber client?
    OR is there some way for me to put in route patterns similar to the App Dial Rules but specify that those patterns are only available when the number is sent enblock so they don't mess with regular dialing? 

    Why dont you apply called party transformation rules and modify the called number as per your need.

  • How to create contact groups in Jabber for Windows

    Attempting to deploy Jabber for Windows.  I can't find where in CUPS to build the contact groups that will deploy to the users.  We are wanting to build our groups by our locations and deploy them from there.  Any help would be greatly appreciated.                  

    Hey Darren,
    With CUPS 8.6(1), you can import users contact lists and as well create groups via the bulk administration page of CUPS.
    This is outlined in the deployment guide below:
    http://www.cisco.com/en/US/docs/voice_ip_comm/cups/8_6/english/install_upgrade/deployment/guide/dgcupc.html#wp1292041
    Keep in mind, this functionality is only available in CUPS 8.6(1) or higher and not in any older version.
    Regards,
    Jas

  • Can't import XDCAM files(.mov) in Premiere for Windows

    Hello.
    I have some problem using XDCAM file in Premiere Pro.
    Actually I captured the XDCAM file(.mov) from MovieRecorder, which is the ingest software for Mac..(http://www.softron.tv/products/movierecorder.html)
    The XDCAM file is opened in Premiere Pro for Mac.
    And  I can play the file in QuickTime player for Win but I can't import the file in Premiere for Windows.
    How can I import the XDCAM(.mov) recorded from Mac in Premiere Pro for Windows?
    Do I have to install any codec or program?
    Please let me know any advice.
    Best regards,
    Donnie Kim

    carz999 wrote:
    "This type of file is not supported, or the required codec is not installed."
    Any suggestions would be appreaciated.
    They have a website with support and a forum.  https://www.videocopilot.net/products/action2/
    Looks like cool stuff.
    They list compatability with Premier Elements.  Perhaps if you post a request there, you will find someone that has been down the road before you with the combination of the two products.   They may also need to know if an adjustment is necessary for PrE11.
    Good luck!

  • Best approach to creating layouts and design pages for windows store 8.1 applications?

    Hi Everybody,
    Actually I want to design pages for windows store 8.1 applications which are compatible for all windows phone with different resolutions. I want best approach for designing pages, currently I am using * type divisions and designing the pages rather than
    that is there any best approach?

    Here is another some helpful docs:
    Laying out an app page
    Laying out your UI (HTML)
    Laying out your UI (XAML)
    Navigation design patterns
    Choosing a layout (HTML)
    Command design patterns
    Guidelines for advertising
    Guidelines for multiple windows
    Guidelines for projection manager
    Guidelines for resizing windows to tall and narrow layouts
    Guidelines for scaling to pixel density
    Guidelines for window sizes and scaling to screens
    Hope helps.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Do I have to pay for creating a iTunes or pay for the apps??

    - Okay, I'm new to iTunes, do we have to pay for creating a iTunes with a monthly fee? Or pay by the drink? (Meaning: Pay for the apps that's not free.)

    iTunes is a Free Download... Apps are either Free or Cost money... depending on the App.

Maybe you are looking for

  • Can i have two separate ipods on one computer?

    My husband has an ipod shuffle and I do too.  His computer is fried - can I download his tunes off his ipod onto my computer and keep them separate?

  • Can alert trigger a RFC

    Hello I have a unique requirement where when a mapping error comes, an alert needs to be triggered and that message should be sent to R/3. How can we achieve it?  We have a status table in R/3 which will capture all error messages.  So, this alert ne

  • Websites no longer show up properly using osx 10.6.8 ffox 36.0.1

    i am pretty sure it's the fact I am still using OSX 10.6.8 but some websites no longer show up properly the way they show up on OSX 10.10 even in safari websites no longer show up the way it does on the new OS. I have also downloaded the latest flash

  • How to enable a locked ipod

    how??

  • Emails disappear without sending

    I've recently started getting a problem with my iPhone: I write an email, hit 'send', and then the email just disappears. Doesn't get sent, doesn't go into a waiting outbox, just disappears into the ether. It seems to happen when I have a weak (or no