How do you access application solution folder without hardcoding?

Working in C# in Visual Community 2013, coding for Desktop only.
In WinForms and WFP, you can open a stream to write to a file without any directory (Streamwriter ("test.txt")) and the file would get saved in the directory the executable is in, generally the \bin\debug folder under wherever you saved
your solution.
Working with Store Apps, how do you mimic that behavior without using hard coded paths or manually navigating to the directory via a FolderPicker or FilePicker?  I can find ways (e.g. KnownFolders) to create an IStorageFile reference to the Pictures
Library, or the Video Library... or if I really want to drive myself nuts, I can go with ApplicationData.Current.LocalFolder and it's Roaming variant, which point to an \User\Name\AppData\Local\Package\DJHAH-JHFDS-FDSFS-FDSFD\...\LocalState directory structure around
10 levels deep... not my preference either.  Oh and I understand you used to be able to use the Documents Library (not that I want to, but it'd be better than any of the other options I've found) but even that isn't easily accessible anymore,
despite still being found under KnownFolders, if I've understand what I've been reading correctly.
I can't seem to pass anything like "." or ".\text.txt" to CreateFileAsync(), for the record.  And I've hunted randomly around the .NET classes, but nothing is being helpful.
Short version:  what namespace.class.property stores a usable IStorageFolder reference to the folder where the currently running executable is located?
An example bit of code that would open up a write stream to a file wherever the solution executable is, and how to capture the path to a string so it could be later passed to OpenAsync() again, would be fantastic.
Thanks for any help.

Thank you kindly, that is indeed very helpful, and yes, it confirms what I'd read earlier that as an indie developer I can't use the Documents folder.  I do have a bit of a follow up question, though... probably no one will see it as I've marked this
question as answered, so I may start a new thread for it if I don't see a reply in a few days.
I get the Sandbox concept, it just seems overrestrictive here.  A simple example is, I make a game which generates save game files.  As anyone who's played Steam games can tell you, one can generally uninstall the game *without* blowing away
your saved games.  I'm not sure how one could employ this concept as an indie game developer however, without using something completely unintuitive like saving save game files to the Video, Pictures or Music libraries, or without forcing the user to
use FolderPickers or FilePickers every save.   If I use the Local data folder, per your source "The folder will be completely erased if the app is uninstalled." Is there any workaround for this situation? What's the conventional method
most people use? FolderPickers and FilePickers every save?  Save games in Video?
Yes, this can be done.  There are 2 options you have.
Options:
(1) First time your user runs your game, you can ask the user to choose a folder to store the saved games, data, and whatever else.  Then you would save this location that the user chooses in the futureaccesslist.
(2) Save the data in the roaming folder of the app.  The data in this folder gets synced to the cloud and stays there for future use.  So, even if the user uninstalls the game and then later reinstalls the game, the data from this folder would
still be there because it was saved in the cloud.
I highly recommend you use option 1.  I can think of several situations where option 2 would pose a problem. 
Regarding the windows sandbox, trust me I was annoyed by the limitations at first, too.  But once you get used to it, it's actually quite nice.  There are always ways to get around certain limitations.  You just need to spend time looking
for them.  For example, one of my apps is a word processor.  My users really wanted the ability to export their documents to pdf.  This was easy to do in wpf and there were plenty of libraries for it.  But in metro, certain limitations
made the old methods impossible.  It took me 3 months to finally get it working.  Once it worked, the sky is the limit. 
The limitations are there for everyone's benefits whether they know it or not.

Similar Messages

  • How do i access the email folder on my macbook air?

    how do i access the email folder on my macbook air?

    OS X doesn't really encourage users to tamper with that folder.  Instead, the idea is to use your email application to keep your mail data in order.
    What are you trying to do?

  • HT4847 How do you access your pictures that you stored on icloud from your ipod touch? I lost my ipod touch and want to get my photos from icloud but i cant seem to find any ******* help. where the **** is icloud and how do you get your stored pictures ba

    How do you access your pictures that you stored on icloud from your ipod?

    sunshinecowgill wrote:
    We have three operational computers, one does not have iTunes on it.  Since Apple is saying I have more than 5 authorized computers, and I can't imagine what they are, I am afraid to deauthorize all my computers.  See what I mean?  I just wanted to ask the question about how I can find out WHICH computers Apple thinks I have authorized, so I can decide if it's safe to deauthorize them all or not. 
    You could have more 5 computers authorized if you ever, for example, reformatted a hard drive or replaced a hard drive without deauthorizing the computer first. Apple's system would see that as a different computer, even though you don't. There's nothing to be afraid of in deauthorizing everything and the reauthorizing what you actually have. You won't lose any data. Mistimp is correct, they can't tell you which computers are authorized.

  • HT4743 I rented a movie on my Apple TV and now I also want to watch the movie on my Mac.  How do I access the rented movie without having to rent again from the Mac?

    I rented a movie on my Apple TV and now I also want to watch the movie on my Mac.  How do I access the rented movie without having to rent again from the Mac?

    Welcome to the Apple community.
    If you rent a movie on the Apple TV, then it can only be watched on the Apple TV. If you want to watch movies on multiple devices, you need to download it to your computer, where you can then transfer it to other devices or stream it to your Apple TV as well as watch it from your Mac.

  • How do you access folders/files in other users Finder list?

    How do you access folders in other users finder list, once you have shared the folder or file

    You should be able to open and view the contents of any directories you have access permissions to using FInder, by navigating the directory tree to the folders in question and opening them as you would your own folders. If you know the full path-name of the directory, you can enter it into the Finder navigator opened by Apple-Shift-G; the dialog that pops up uses the same directory listing method as all unix systems, and has tab completion for ease of use. In general, all users have their home directories in /Users/, or you can simply use ~/../<name> to go to the home folder of a user via the parent (..) directory of your home (~) directory. If you are experiencing bugs or errors with this, as opposed to simply not knowing how to do this, please post any details of your experience so that others can help troubleshoot your problems.

  • How do you uninstall applications in OS X specifically classic (os 9)

    how do you uninstall applications in OS X specifically classic (os 9)

    Do you mean you want to remove Classic (OS 9)?
    If so, there's not much to it. First, be sure you don't need, or plan to use any OS 9 or earlier applications. You'll need Classic to run them if you do. Second, back up any files created with those older apps if you need to.
    Once you're ready, delete the following folders:
    System Folder (NOT System. That's the OS X system folder.)
    Applications (Mac OS 9) (NOT Applications. Those are the OS X apps.)
    If OS X complains that it can't empty the trash because "items are in use", restart and you should then be able to empty the trash.

  • How do you access 'finder' when building Smart Previews in Lr5.

    How do you access 'finder' when building Smart Previews in Lr5

    C,
    What type of backup was it? I'm hoping you were using Time Machine or creating a Bootable Clone using Super Duper or Carbon Copy Cloner. If that is the case then I'd recommend starting over so you can restore all your data, applications, settings etc... You missed your first chance when you turned on the new system and it asked if you had another Mac you wanted to migrate from. You can get a  second chance to do this and migrate. Please carefully look over Pondini's Lion Setup Assistant tips beginning where he talks about Second Chance....and make sure you have the proper cable before starting. If your backup EHD has a USB connection that will be fine if it has a FireWIre 400 connection you will a cable like this one from Amazon.
    You can find these at your local computer store, Walmart, Radio Shack etc..

  • How do you access "trouble shoot" for mail.  My AOL account is set up on the mail icon but it some how defaulted to another Wi fi account and could not receive email.  We reset the the Wifi but somehow didn't complete the process.

    How do you access "trouble shoot" for mail.  Our AOL account is set up on the mail icon but somehow it defaulted onto another nearby Wifi account while everything else that was running stayed on our router.  We were unable to receive email on the AOL account and were directed to trouble shoot.  We reset the Wifi account but somehow didn't save it correctly.  Now we cannot get back in to reset it again.  Direction??

    Hello
    I don't really understand your question. The Mail application cannot independently access a different wifi network from the one your computer is using.
    Are you trying to troubleshoot your wifi (ie, you can't get into your own wireless network), or the Mail program (you can't get email)? Are there any error messages you see when you try to do one or the other?
    Matt

  • I have a Verizon IPhone 4 and i can't figure out how to get my ringtones from an app to my iTunes account, it doesn't have a tab for Ringtones! I have tried unplugging it and checking if would show up but it didn't, how do you enable the ringtone folder?

    I have a verizon IPhone and i can't figure out how to get my ringtones from the app to iTunes, my account doesn't have a ringtone section in the liRingtone Folder?brary, how do you enable the ringtone folder?

    Edit > Preferences.  Select the check box for Ringtones, this will add them to the listing in iTunes. 
    Not sure that really answers your question though.

  • How do you access updates to apps from the App store after changing to a new ID because the password on the old ID was changed and you don't know what it is now?

    How do you access updates to apps from the App store after changing to a new ID because the password on the old ID was changed by the former husband and you don't know what it is now?  And you set up your own new ID and account but can NOT access the updates, from the App store for the many apps that you already have, because they require that you sign in with that former now inaccessible ID and account and password?  Call it a problem of modern times and changing relationships, if you want to be charitable.

    So I guess it will only be new apps that I download that are allowed to give me their updates while 13 updates wait for me on an ID I can no longer access.
    Yes...  sorry.
    In the future, if need be, you can re download your purchases for free  >  Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Good rule of thumb is to back up your purchases regardless  >  Mac App Store: Backing up your app purchases

  • How do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the onli

    how do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the online photoshop, and I really want to create my own customized url and post photos to my gallery and share them with the world, family, and friends, but i need help because i can't figure how to do any of this, would really appreciate feedback and assistance, thanks, - claire conlon

    To add to sig's reply, "calibrating" does not calibrate Lithiu-Ion batteries, it calibrates the charge reporting circuitry.  If you look at the effect of deep discharging Lithium-Ion batteries in the data from the independent test group, Battery University, you will see that doing so shortens the life of the battery significantly. It looks like an optimum balance between use and life is at a discharge level of 50%.

  • How do you access files from an external harddrive connected to TC through USB from iPad or windows computer?

    How do you access external hard drive data that is connected to TimeCapsule through USB from iPad or knows based computer?

    Filebrowser for the iPad does this very well.
    FileBrowser - Access files on remote computers for iPhone, iPod ...
    Cannot help on Windows, but another PC guy might be able to answer. Some possible clues here:
    http://support.apple.com/kb/HT1331

  • Iphone ios5..I upgraded to ios5 on my iphone 4 and in the demo video on the Apple website it shows a cute animation screen with the user dragging what appears to be balloons on a string how do you access this screen?

    iphone ios5..I upgraded to ios5 on my iphone 4 and in the demo video on the Apple website it shows a cute animation screen with the user dragging what appears to be balloons on a string how do you access this screen?
    Not sure if this is a game or app or not...it shows nothing about it and explains nothing about it...but it is there on the demo video on the apple website for the add to upgrade to ios 5...it shows the user dragging threads and the little icon monster at the bottom of the screen catches them

    Yea thats a game called "Cut the Rope" and it can be found in the App Store for $0.99 or you can buy the Lite version for free.

  • How do you create a Spam folder in Mail

    How o you create a Spam folder in Mail?

    This depends on your email provider but marking an email as Spam/Junk may automatically create a Spam/Junk folder.
    Swipe from right to left on the email preview, select "More", and touch "Move to Junk"

  • How do you create a new folder in the library folder

    How do you create a  new folder in the library?

    In the user Library? Open Finder and select Go then press the Option key. In the list you will see your user Library folder (underneath Home). Click it to open it. Now you can add a folder inside. You can left click/hold and drag the Library icon at the top of the Finder window to your Finder Sidebar so it's always avaliable.

Maybe you are looking for

  • MacBook Pro Mid-2012 13 inch disfunction of keyboard and trackpad

    This evening, seemingly out of nowhere, my trackpad, and then my keyboard, progressively seemed to degenerate into a state of semi-unresponsiveness. Simply put; none of the keys on my computer will work. I tried bringing everything back to default. T

  • Connecting midi?

    I have tried to connect my Kawai380 electric piano to a macbook pro via cable which has input and output from kb sockets, a midi junction boxand a usb connection to my mac but they won't talk to each other. Have tested using Sibelius and other progra

  • Classical Music storing and sorting

    Hi all, I love classical music and have a lot of them in my iTunes and iPod 30G. I'm used to editing their tags like this: - Name: BWV 1048 - Brandenburg Concertos #3 In G - 1. Allegro - Artist: Capella Istropolitana/ Bohdan Warchal - Album: Bach: Br

  • What is my id code ?

    What is my id code ? how to create or find....

  • MAIL opens very slowly.

    MAIL takes about 3 minutes to open.  And it takes several minutes to catch up when it's been idle for a while.  Once it's running it responds normally, but "checking in" to MAIL has become impractical.  I have 4.4 GB of stored mail, which will come c