Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:04:26+00:00 2026-06-01T01:04:26+00:00

I have built an app that works only when not run as a Windows

  • 0

I have built an app that works only when not run as a Windows service. Well, the service runs, but it doesn’t do what it should. The service uses the Local Service account. So to kick off debugging, I thought I’d start with something simple: have it create a directory when it starts:

Directory.CreateDirectory(
    Environment.SpecialFolder.LocalApplicationData + "\\MyService");

When I started the service, it stopped almost immediately and Windows reported that fact. When I commented out the above statement, recompiled and re-installed, the service ran without stopping.

Obviously the above line throws an exception of some sort. I have no way of logging the error because I can’t write to the file system. Any ideas why Local Service can’t create a directory in its own %LOCALAPPDATA%?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:04:28+00:00Added an answer on June 1, 2026 at 1:04 am

    You should use GetFolderPath with LocalApplicationData like so:

    string folderName = Path.Combine(Environment.GetFolderPath(
        Environment.SpecialFolder.LocalApplicationData), 
        "MyService");
    
    Directory.CreateDirectory(folderName)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net mvc app that is built to run as standard web
I have built an app that plays lots of sounds the easy way: AudioServicesPlaySystemSound(someSoundID);
I have an iphone app that I built based off a tutorial (for a
I have built a simple C#.Net app on a M/C with only .Net FX
I have a flex 4.5 php app that runs perfectly on localhost. When I
im learning the google app engine framework and service and for that i built
i have an app that when i run on xcode connects with the database
Sorry but I found no clear answer on that. I have an iphone app
I have built a cakephp app that needs the user to login or register(for
I have a Flex App that allows you to dynamically build an animation. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.