Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Method CRService.crRequest can not be reflected. Pin
NarVish16-Mar-12 1:47
NarVish16-Mar-12 1:47 
Questionc# Pin
mukesh methaniya15-Mar-12 22:36
mukesh methaniya15-Mar-12 22:36 
AnswerRe: c# Pin
BobJanova15-Mar-12 23:08
BobJanova15-Mar-12 23:08 
JokeRe: c# Pin
ZurdoDev16-Mar-12 6:23
professionalZurdoDev16-Mar-12 6:23 
GeneralRe: c# Pin
R. Giskard Reventlov16-Mar-12 6:56
R. Giskard Reventlov16-Mar-12 6:56 
GeneralRe: c# Pin
computerpublic16-Mar-12 11:43
computerpublic16-Mar-12 11:43 
GeneralRe: c# Pin
ZurdoDev16-Mar-12 12:58
professionalZurdoDev16-Mar-12 12:58 
QuestionCannot Resolve Path Error Pin
computerpublic15-Mar-12 16:31
computerpublic15-Mar-12 16:31 
I wrote this small program from an example in the C# book and it compile fine, but gives a path error for the file that I am reading. I created an external file at c:\tempPath

Can someone please advise?
Thanks.

using System;

using System.IO;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace ConsoleApplicationTEST2

{

class Program

{

static void Main(string[] args)

{

string tempPath = Path.GetTempFileName();

string tempPath2 = Path.GetTempFileName();



if (File.Exists(tempPath))

{

byte[] data = File.ReadAllBytes("c:\tempPath");

File.WriteAllBytes(tempPath2, data);

Console.WriteLine("First byte: {0}", data[0]);

Console.WriteLine("Last byte: {0}", data[data.Length]);

Console.WriteLine(data.Length);

}

}

}

}





OUTPUT:



Unhandled Exception: System.ArgumentException: Illegal characters in path.

at System.IO.Path.CheckInvalidPathChars(String path)

at System.IO.Path.GetFileName(String path)

at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,

FileShare share)

at System.IO.File.ReadAllBytes(String path)

at ConsoleApplicationTEST2.Program.Main(String[] args) in C:\Users\computerpu

blic\Desktop\ConsoleApplicationTEST2\ConsoleApplicationTEST2\Program.cs:line 20

Press any key to continue . . .
AnswerRe: Cannot Resolve Path Error Pin
Peter_in_278015-Mar-12 17:19
professionalPeter_in_278015-Mar-12 17:19 
GeneralRe: Cannot Resolve Path Error Pin
computerpublic16-Mar-12 1:41
computerpublic16-Mar-12 1:41 
GeneralRe: Cannot Resolve Path Error Pin
ZurdoDev16-Mar-12 6:24
professionalZurdoDev16-Mar-12 6:24 
GeneralRe: Cannot Resolve Path Error Pin
ProEnggSoft16-Mar-12 14:42
ProEnggSoft16-Mar-12 14:42 
AnswerRe: Cannot Resolve Path Error Pin
PIEBALDconsult15-Mar-12 17:40
mvePIEBALDconsult15-Mar-12 17:40 
GeneralRe: Cannot Resolve Path Error Pin
ProEnggSoft16-Mar-12 14:44
ProEnggSoft16-Mar-12 14:44 
AnswerRe: Cannot Resolve Path Error Pin
BobJanova15-Mar-12 23:07
BobJanova15-Mar-12 23:07 
GeneralRe: Cannot Resolve Path Error Pin
Pete O'Hanlon15-Mar-12 23:29
mvePete O'Hanlon15-Mar-12 23:29 
GeneralRe: Cannot Resolve Path Error Pin
BobJanova16-Mar-12 0:57
BobJanova16-Mar-12 0:57 
GeneralRe: Cannot Resolve Path Error Pin
Pete O'Hanlon16-Mar-12 1:06
mvePete O'Hanlon16-Mar-12 1:06 
AnswerRe: Cannot Resolve Path Error Pin
V.16-Mar-12 2:01
professionalV.16-Mar-12 2:01 
AnswerRe: Cannot Resolve Path Error Pin
Luc Pattyn16-Mar-12 4:17
sitebuilderLuc Pattyn16-Mar-12 4:17 
GeneralRe: Cannot Resolve Path Error Pin
computerpublic16-Mar-12 11:46
computerpublic16-Mar-12 11:46 
GeneralRe: Cannot Resolve Path Error Pin
Richard Andrew x6416-Mar-12 13:11
professionalRichard Andrew x6416-Mar-12 13:11 
GeneralRe: Cannot Resolve Path Error Pin
ProEnggSoft16-Mar-12 14:50
ProEnggSoft16-Mar-12 14:50 
Questioncrone file Pin
altafmohd15-Mar-12 8:39
altafmohd15-Mar-12 8:39 
AnswerRe: crone file Pin
Dave Kreskowiak15-Mar-12 9:19
mveDave Kreskowiak15-Mar-12 9:19 

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.