|
Sir as u said i have pasted that code but the same thing is happening again.Again after that line code goes to that event dont know why....and one more think backfile is being created but there is nothing in the backup file because after that line code is not executing.....
|
|
|
|
|
I consumed a wsdl file in a windows application as webreference. I called a method from the reference.
At runtime, I'm getting the exception "Method CRService.crRequest can not be reflected."
at below line.
CRService cr = new CRService();
Please guide me to solve this exception
|
|
|
|
|
The likeliest problem here is that CRService.crRequest uses a datatype that .NET doesn't recognise (based on the wsdl is imported).
|
|
|
|
|
How can we identify which type causes the problem.
|
|
|
|
|
how to draw text and how to move,resize on a canvas in wpf
|
|
|
|
|
|
That's the UK's version of google. No offense, but the original is better.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
But Google was financed by a limey so, really, owned by him: the 2 chipmunk boys were just his hacks.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
I am very sorry. Were you trying to add something useful that would help a novice like myself, or were you trying to prove that you can form complete a sentence. Honestly, I am only looking for constructive help. Nothing else.
|
|
|
|
|
I think you responded in the wrong spot. This thread is from a very generic question and the first response, not even from me, was to search google. This isn't even your question. Then a few of us enjoyed a little humor during a Friday workday.
I actually did provide you an answer to one of your questions.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
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 . . .
|
|
|
|
|
You need to learn about character escaping in strings.
computerpublic wrote: byte[] data = File.ReadAllBytes("c:\tempPath"); That string is (shown 1 character per line for clarity)
c
:
tab character (\t)
e
m
p
P
a
t
h
What you probably mean is "c:\\tempPath" .
While you are at it, read up on Unicode .
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Peter,
When I make it ("C:\\tempPath", it gives me the following error:
Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'c:\te
mpPath'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, I
nt32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions o
ptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolea
n useLongPath)
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 18
Press any key to continue . . .
|
|
|
|
|
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.
|
|
|
|