Click here to Skip to main content
15,913,303 members
Home / Discussions / C#
   

C#

 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk32-Jan-15 11:10
turbosupramk32-Jan-15 11:10 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk33-Jan-15 19:13
turbosupramk33-Jan-15 19:13 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
Dave Kreskowiak4-Jan-15 4:30
mveDave Kreskowiak4-Jan-15 4:30 
GeneralRe: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. - why? Pin
turbosupramk34-Jan-15 6:34
turbosupramk34-Jan-15 6:34 
Questionarray property Pin
TMattC1-Jan-15 5:13
TMattC1-Jan-15 5:13 
AnswerRe: array property Pin
Thomas Daniels1-Jan-15 5:29
mentorThomas Daniels1-Jan-15 5:29 
GeneralRe: array property Pin
PIEBALDconsult1-Jan-15 5:47
mvePIEBALDconsult1-Jan-15 5:47 
AnswerRe: array property Pin
OriginalGriff1-Jan-15 6:07
mveOriginalGriff1-Jan-15 6:07 
GeneralRe: array property Pin
harold aptroot1-Jan-15 6:16
harold aptroot1-Jan-15 6:16 
AnswerRe: array property Pin
BillWoodruff1-Jan-15 9:23
professionalBillWoodruff1-Jan-15 9:23 
AnswerRe: array property Pin
BillWoodruff2-Jan-15 2:48
professionalBillWoodruff2-Jan-15 2:48 
Question(solved) Multiple reads of a file when it is open in another application ? Pin
BillWoodruff1-Jan-15 4:15
professionalBillWoodruff1-Jan-15 4:15 
AnswerRe: Multiple reads of a file when it is open in another application ? Pin
OriginalGriff1-Jan-15 4:42
mveOriginalGriff1-Jan-15 4:42 
Whenever you open the file for writing, you establish an exclusive lock on it - and no other process can get access to the file for read or write. So you need to look at your "simple text editor" and find out exactly what it does with files - some (primitive) ones open the file for read and write and hold it until they are finished (which is a pain if you have automated backups running)


And that sample code opens the same file twice...first to create a FileStream, and then again to actually read the data. You don't need the stream at all:
C#
theFileContents = File.ReadAllLines(thePath); 
creates it's own stream and reads the file through that. Try without the stream, and see if the problem goes away.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: Multiple reads of a file when it is open in another application ? Pin
BillWoodruff1-Jan-15 6:03
professionalBillWoodruff1-Jan-15 6:03 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
OriginalGriff1-Jan-15 6:12
mveOriginalGriff1-Jan-15 6:12 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
BillWoodruff1-Jan-15 21:55
professionalBillWoodruff1-Jan-15 21:55 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
OriginalGriff1-Jan-15 23:05
mveOriginalGriff1-Jan-15 23:05 
AnswerRe: Multiple reads of a file when it is open in another application ? Pin
Pete O'Hanlon1-Jan-15 23:04
mvePete O'Hanlon1-Jan-15 23:04 
GeneralRe: Multiple reads of a file when it is open in another application ? Pin
BillWoodruff2-Jan-15 2:22
professionalBillWoodruff2-Jan-15 2:22 
QuestionReference to array element Pin
Krishnakumartg31-Dec-14 22:55
Krishnakumartg31-Dec-14 22:55 
AnswerRe: Reference to array element Pin
OriginalGriff31-Dec-14 23:56
mveOriginalGriff31-Dec-14 23:56 
GeneralRe: Reference to array element Pin
BillWoodruff1-Jan-15 4:24
professionalBillWoodruff1-Jan-15 4:24 
GeneralRe: Reference to array element Pin
OriginalGriff1-Jan-15 4:34
mveOriginalGriff1-Jan-15 4:34 
GeneralRe: Reference to array element Pin
harold aptroot1-Jan-15 4:44
harold aptroot1-Jan-15 4:44 
GeneralRe: Reference to array element Pin
Krishnakumartg26-Jan-15 18:52
Krishnakumartg26-Jan-15 18:52 

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.