|
That's because it is a directory. You need to point to a file.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
5!
|
|
|
|
|
Yeah, what he said. Or you could use a verbatim string -- @"c:\tempPath" .
|
|
|
|
|
5!
|
|
|
|
|
Or: "c:/temppath". .Net allows the separator to go either way.
|
|
|
|
|
BobJanova wrote: .Net allows the separator to go either way.
There are soooooo many jokes just crawling all over that statement.
|
|
|
|
|
Yes, but this is a serious forum, so I thought it would be okay
|
|
|
|
|
BobJanova wrote: Yes, but this is a serious forum,
Is it? Good gravy man, that's news to me.
|
|
|
|
|
It looks like you want to 'copy' a file from one directory to another. You give it 2 arguments: source and destination. correct?
In that case I would rather go for:
byte[] data = File.ReadAllBytes(tempPath);
"C:\tempPath" denotes a directory ,not a file.
PS: note that the other comments are valid, the \ backslash character needs to be escaped as follows.
"C:\\tempPath\\"
@"C:\tempPath\"
Another thing is see going wrong is this line:
Console.WriteLine("Last byte: {0}", data[data.Length]);
Console.WriteLine("Last byte: {0}", data[data.Length-1]);
Hope this helps.
V.
|
|
|
|
|
computerpublic wrote: static void Main(string[] args)
string tempPath = Path.GetTempFileName();
string tempPath2 = Path.GetTempFileName();
if (File.Exists(tempPath))
{
byte[] data = File.ReadAllBytes("c:\tempPath");
Oh my.
1.
As Path.GetTempFileName() tries to provide you with a randomly chosen file name in order NOT to clash with existing files, how on earth do you expect File.Exists() to ever return true?
2.
Code should be put inside PRE tags, to preserve formatting and improve readability.
3.
And if there is some code sitting in between both method calls, you really should have indicated so.
4.
There is absolutely no relation between a variable called tempPath, and a file path with the value @"C:\tempPath".
Did you skip your morning coffee?
|
|
|
|
|
I changed the file name to "c:\\temp" and it still does not work.
|
|
|
|
|
The file name is stored in your variable tempFile .
Why are you giving it a string literal that says "C:\tempFile"?
Try
byte[] fileData = File.ReadAllBytes(tempFile);
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
5!
|
|
|
|
|
can any body tell me how to create cron file in .net using c# for web application..
|
|
|
|
|
Considering Windows has no concept of a "cron" file, that's pretty much impossible to do.
Are you talking about scheduling a task to run as some future point?
|
|
|
|
|
Dave Kreskowiak wrote: pretty much impossible to do
its just a matter of time
Failure is not an option; it's the default selection.
|
|
|
|
|
hmmmmm ok
|
|
|
|
|
hmmm ok
|
|
|
|
|
What is your exact requirement? for scheduling tasks it will be better creating a desktop application & using windows scheduler to schedule it....
|
|
|
|
|
its ok ...and thank you
|
|
|
|
|
Hi,
I've a wsdl file and I added that file as service reference to my class library project.
When I tried to aceess functions from that service, I couldn't able to create object for that service. Its looking very simple problem, but couldn't able to trace where I'm missing.
|
|
|
|
|
What is error you are getting? Can you post some code?
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
I didn't write code so far. I just added the wsdl as my service reference and named as ServiceReference1. Then I tried to create object for the ServiceReference1, but that class is not getting detected. So couldn't able to add objects for that;
|
|
|
|
|
ServiceReference1 is not the class. It is the namespace in which you will have classes to make service method calls. I suggest you view the namespace in Object Browser.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
By mistake, I typed ServiceReference1 as class.
I opened ServiceReference1 in object browser. its showing TestCRWSDL namespace, which is my project name.
|
|
|
|