Solved

C# Read\write access to the programs files directories in XP

Posted on 2010-11-09
6
565 Views
Last Modified: 2012-05-10
Hello Experts,

I have a self-repairing application that requires access to a folder under the program files directory.  Weebo (yeah, I named it after the maintenance droid in flubber...), checkes the App folder (c:\program files\bob\), deletes all of the template files, then copies current template files.

Any discussion of technique is moot for this particular application, but par for the course for future endeavors...  Anyways, I know it worked on most machines until recently.  The weird thing is that it works on a PC pacted up to SP3, but not on a system that was loaded with SP3 (and then Weebo is installed)

Can someone tell me how to get control of my directory back?  It is a big endevor to fix this otherwise.
0
Comment
Question by:the_b1ackfox
  • 3
  • 3
6 Comments
 
LVL 6

Expert Comment

by:r3nder
ID: 34099303
protected void CleanImageFolder()
{
    string imgFolder = Server.MapPath("~/lab/maskemail/img/");
    string[] imgList = Directory.GetFiles(imgFolder, "*.jpg");
    foreach (string img in imgList)
    {
        FileInfo imgInfo = new FileInfo(img);
        if (imgInfo.LastWriteTime < DateTime.Now.AddMinutes(-3))
        {
            imgInfo.Delete();
        }
    }
}
0
 
LVL 9

Author Comment

by:the_b1ackfox
ID: 34100540
I had originally asked this question as I was running out the door from work, and I have come to realize that my question isn't very well stated.  So I am going to try and restate it now.

My App (weebo) is crashing on some Windows XP systems while it is trying to delete files.  I initially thought that it wasn't deleting any files at all...   but upon further inspection, it seems as though some of the files are deleted indeed.

Since it works flawlessly on a few systems, I figured the problem was systemic (and it is, just not how I thought)  It is systemic in the fact that I stopped troubleshooting, because I thought the problem was with the OS updates.

I now think the answer lies in adding logging functionality, and trapping/debugging the errors...  :)
0
 
LVL 6

Accepted Solution

by:
r3nder earned 500 total points
ID: 34102444
use try catch statements and print the error to the screen - my first thought is that it is going to be "run as administrator" issues
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 9

Author Comment

by:the_b1ackfox
ID: 34142116
still working on putting this into testing...  weird part, is I now have it running on a defferent computer...  
0
 
LVL 6

Expert Comment

by:r3nder
ID: 34142291
Odd, let me know all the symptoms so I can better understand whats going on and get you up and running :)
Thanks
R3nder
0
 
LVL 9

Author Comment

by:the_b1ackfox
ID: 34478130
R3nder... sorry about that, I didn't mean to not get back to you.  I am awarding you points and an apology!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question