Avatar of Mahen Singh
Mahen Singh
 asked on

C# Image Problem

when I save a record with Image, it will save perfectly but when I updated the record again for Image it will say System.IO.IOException: "The file exists" on windows 7 64 bit . The installation directory is with read only attribute , I tried the best to remove this attribute but could not make it.
Can u help me out
InstallationC#Windows 7Microsoft SQL Server

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon
Mahen Singh

ASKER
ASKER CERTIFIED SOLUTION
Gustav Brock

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mahen Singh

ASKER
I am doing in same way.. but in some cases this error occurs ....I have also attached the screenshot
Gustav Brock

Well, the program files folder is definitely not the place to store user files, so try playing by the rules and use %localapppath%.

/gustav
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Mahen Singh

ASKER
Can u explain it with detail.. did not get your point exactly..?
Gustav Brock

Try to save your files in a sub folder of the %localappdata%.

The Program Files folder is not intended for this purpose.

/gustav
Mahen Singh

ASKER
There must be solution.. I think , if we install on client machine it would be installed on program file directory..
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gustav Brock

No. Normal user rights doesn't grant right to save anything in the Program Files folder. You need Admin rights, and a normal user should never be required to run your application with admin rights.

It's up to you to control the installation.
Mahen Singh

ASKER
k.. then how to give the rights to normal user ....like admin rights. In that case it wont be a prob.
Gustav Brock

You can set your application to require admin rights. That will pop the usual warning message and ask the user for credentials for an admin account.
But to save some pictures, this is bad practice and should be avoided. Again, use %localappdata% for storing user documents and files.

/gustav
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Gustav Brock

Question was answered.