Click here to Skip to main content
15,888,242 members
Home / Discussions / C#
   

C#

 
AnswerRe: Removing duplicates from large text files (Performance needed) Pin
Doug Goulden29-Apr-09 15:17
Doug Goulden29-Apr-09 15:17 
QuestionMessage Removed Pin
29-Apr-09 11:39
professionalN_tro_P29-Apr-09 11:39 
AnswerRe: How to Load data into user settings Pin
DaveyM6929-Apr-09 12:07
professionalDaveyM6929-Apr-09 12:07 
AnswerRe: How to Load data into user settings Pin
Henry Minute29-Apr-09 13:10
Henry Minute29-Apr-09 13:10 
QuestionUm... it works when I F5 but not when I CTRL - F5...? Pin
Edmundisme29-Apr-09 11:27
Edmundisme29-Apr-09 11:27 
AnswerRe: Um... it works when I F5 but not when I CTRL - F5...? Pin
Eddy Vluggen29-Apr-09 12:45
professionalEddy Vluggen29-Apr-09 12:45 
GeneralRe: Um... it works when I F5 but not when I CTRL - F5...? Pin
Edmundisme29-Apr-09 12:47
Edmundisme29-Apr-09 12:47 
QuestionC# - File Permission Pin
malharone29-Apr-09 10:44
malharone29-Apr-09 10:44 
This is a very trivial question, but I have not had much chance in finding a solution. I have searched Google / blogs, but apparantly either there is no solution or I searched for the wrong keyword. Any help will be greatly appreciated.

I have an application (similar to a wizard) and I need to validate whether the user has the permission to write/read from a particular location.

I the following function (below), but I am always getting the value "true" eventhough from Windows Explorer when I try to navigate to the location, I'm always getting an error (eg. "You need permission to perform this action. [Retry] [Cancel]").

static bool CanReadAndWrite(string path)
{
      var perm = new FileIOPermission(
                  FileIOPermissionAccess.Write & 
                  FileIOPermissionAccess.Read &
                  FileIOPermissionAccess.PathDiscovery,
                  path);
      try
      {
            perm.Demand();
            return true;
      }
      catch
      {
            return false;
      }
}


Many of the blogs/articles suggest that I should attemt to write to the location anyways, and if the write operation is successful, then I can proceed to write the main data. If there is an exception creating the stram then there is a perimission issue.

But this solution would NOT work for me. The application has two "pages".
- First wizard page: user selects the file path
- Second wizard page: specify options
- Third wizard page: write data

Each of the pages has Cancel button and the expectation is that user NOT be able to continue to the 2nd page if permission is denied. The above suggested solution would WORK fine if the user does not have permission. But if the user DOES have permission, then the validation check in Page # 1 would have created new file and/or overwrote an existing file with 0 bytes -- and if user cancels on Page #2 then there is a useless file on the file system.

So anyways, what should I do (clean implementation) to check for file permision?
I'm using Vista, .Net 3.5.

Thanks,

- Malhar
AnswerRe: C# - File Permission Pin
Jimmanuel29-Apr-09 11:19
Jimmanuel29-Apr-09 11:19 
AnswerRe: C# - File Permission Pin
Luc Pattyn29-Apr-09 11:33
sitebuilderLuc Pattyn29-Apr-09 11:33 
GeneralRe: C# - File Permission Pin
malharone29-Apr-09 13:17
malharone29-Apr-09 13:17 
QuestionHelp with Web Service Upload Pin
charles Frank29-Apr-09 10:16
charles Frank29-Apr-09 10:16 
QuestionHow can I use cookies stored by Internet Explorer 7(in Vista) in my WinForms application? Pin
rebulanyum29-Apr-09 10:08
rebulanyum29-Apr-09 10:08 
AnswerRe: How can I use cookies stored by Internet Explorer 7(in Vista) in my WinForms application? Pin
Henry Minute29-Apr-09 10:59
Henry Minute29-Apr-09 10:59 
AnswerRe: How can I use cookies stored by Internet Explorer 7(in Vista) in my WinForms application? [modified] Pin
rebulanyum30-Apr-09 4:36
rebulanyum30-Apr-09 4:36 
QuestionWhy pictures aren't shown in listview Pin
Aljaz11129-Apr-09 9:06
Aljaz11129-Apr-09 9:06 
AnswerRe: Why pictures aren't shown in listview Pin
Henry Minute29-Apr-09 9:34
Henry Minute29-Apr-09 9:34 
GeneralRe: Why pictures aren't shown in listview Pin
Aljaz11129-Apr-09 9:47
Aljaz11129-Apr-09 9:47 
GeneralRe: Why pictures aren't shown in listview Pin
Aljaz11129-Apr-09 10:01
Aljaz11129-Apr-09 10:01 
GeneralRe: Why pictures aren't shown in listview Pin
Dan Neely29-Apr-09 10:12
Dan Neely29-Apr-09 10:12 
GeneralRe: Why pictures aren't shown in listview Pin
Henry Minute29-Apr-09 10:18
Henry Minute29-Apr-09 10:18 
GeneralRe: Why pictures aren't shown in listview Pin
Aljaz11129-Apr-09 10:25
Aljaz11129-Apr-09 10:25 
GeneralRe: Why pictures aren't shown in listview Pin
Henry Minute29-Apr-09 10:35
Henry Minute29-Apr-09 10:35 
GeneralRe: Why pictures aren't shown in listview Pin
Aljaz11129-Apr-09 10:43
Aljaz11129-Apr-09 10:43 
GeneralRe: Why pictures aren't shown in listview Pin
Henry Minute29-Apr-09 10:54
Henry Minute29-Apr-09 10:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.