|
This has been answered before. Search the comments (using the link above the messages box).
Also, if you create a multi-line text box and send the content as a single string, you may, in fact, be able to do this. I answered a previous question witha programmatic way that worked similar to this but I don't remember it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Try "\n\r" or "\r\n". As much as I remember "\n\r" is correct.
Mazy
No sig. available now.
|
|
|
|
|
I tried to create a method to open a document, but I got "The file isn't specified" error message. I debugged and saw the FileName contained like "C:\MyProject\Documents\my.doc", and it seems to be ok. Here is the code:
public void OpenDoc(string myDocumentsPath,
string fileName)
{
Process myProcess = new Process();
try
{
myProcess.StartInfo.FileName = myDocumentsPath + fileName;
myProcess.StartInfo.Verb = "Open";
myProcess.StartInfo.UseShellExecute = true;
myProcess.StartInfo.RedirectStandardOutput = false;
myProcess.Start();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
Console.WriteLine(e.Message +
". You do not have permission to open this file.");
}
}
If you find something is wrong, please let me know.
Thank you for your help,
|
|
|
|
|
um... I might be able to help...
What exactly are you sending as the arguments?
(string myDocumentsPath, string fileName)
/\ |_ E X E GG
|
|
|
|
|
For example, the arguments are:
string myDocumentsPath = "C:\MyProject\Documents\"
strin fileName = "My.doc"
I hope this helps. Thanks,
|
|
|
|
|
Um... If it still dosn't work after what Heath Stewart said....
Add a @ to myDocumentsPath ... like this...
string myDocumentsPath = @"C:\MyProject\Documents\";
does it work?
|
|
|
|
|
You create the ProcessStartInfo object, but you're not passing it to Process.Start ! Therefore, no executable name or document name is being specified in order to start it. You're just trying to start an unknown process.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I changed it as you recommend me, but I have still had the same problem, "the system can't find the file specified." If you have some ideas to fix it, please let me know. Here is the code. The string myDocumentsPath is "C:\MyProject\Documents\" and the string fileName is "myword.doc".
public void OpenDoc(string myDocumentsPath,
string fileName)
{
try
{
string tempFileName = myDocumentsPath + fileName;
Process.Start(tempFileName);
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
Console.WriteLine(e.Message + ". You do not have permission to open this file.");
}
}
|
|
|
|
|
Why don't you do what I said, along with what you already got from Heath Stawart. Then it will work...
/\ |_ E X E GG
|
|
|
|
|
I have a file of MIME type "application/vnd.adobe.xfdf". I need the WebBrowser to load this file from a string (without using the Navigate method).
Part of an application I'm developing has to do with reports. To reduce security problems I don't save any of the reports to disk. In the past I just loaded HTML into the WebBrowser by using the IHTMLDocument2 interface of WebBrowser.Document. I then did write() and close(). However this doesn't work anymore since I'm not loading HTML. I need to load a XFDF (PDF) document.
|
|
|
|
|
I don't know why it didn't hit me earlier. Maybe I've been working for too long and should take a break.
I'm just going to use the Arobat Reader ActiveX control
Still would be nice if you could update MIME type
|
|
|
|
|
You can use <meta http-equiv="Content-Type" content="application/vnd.adobe.xfdf"> as the first META tag (to be safe). If doing this from ASP.NET, you'd simply set this MIME type in the HttpResponse.ContentType property before writing to the response stream itself.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath. I understand that part clearly. However, the WebBrowser is not navigating, therefore it is not reading any response stream. The way I was trying to do (navigate to about:blank and set the htmldoc) it just doesn't work.
I just switched to using the PDF ax ctrl. Besides its silly to have the PDF control hosted inside a webbrowser control when you don't need to navigate to anything. Just setting the src of the pdf control would work fine. (Originally I wanted to make the data more secure by not writing it to disk. I found another workaround for that)
|
|
|
|
|
Does anyone know how to drag/drop files from a C# application into Windows Explorer?
I've been trying to find an example on the web for hours - no luck
Elena
|
|
|
|
|
DataObject data=new DataObject();
data.SetData(DataFormats.FileDrop,new string[]{filename});
control.DoDragDrop(data,DragDropEffects.All);
|
|
|
|
|
Thak you!!! It works! I can finally go home
Elena
|
|
|
|
|
I need a small pdf component that does nothing more than fill a feild.
I've found nice components but the prices are through the roof. PDFKit has the functionality I need, however the pricing is just outrageous. I don't mind if the price < 100
|
|
|
|
|
Has anyone heard of Adobe XML/PDF format? XDP and XFDF. This stuff is awesome.
Take a look at these links :
http://www.adobe.com/enterprise/xml.html
http://www.planetpdf.com/planetpdf/pdfs/pdf2k/03w/defurio_pdfxmlforms1103.pdf
http://www.adobe.com/enterprise/pdfs/xml_whitepaper.pdf
This is going to be the best solution to my problem if I figure out how it works. Stilling looking for that PDF component.
|
|
|
|
|
We ended up using a 3rd party library on something we were working on. I don't remember this XML stuff being available back then. I only remember finding the Adobe SDK, which is very low level (roll your own layout basically).
This seems to have all the functionality we needed. Let me know how it goes for you.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I ended up using the XML FDF. When the webbrowser picks up the type "application/vnd.adobe.xfdf" it loads Acrobat Reader. The XFDF file is a simple xml file that contains the feild information. Acrobat Reader figures out what pdf this applied to by looking at the <f href="___.pdf"> tag. This is great !!
|
|
|
|
|
That like it might work for what we used the third party tool for.
We basically have an online "application" (as in apply for service) that currently uses several ASP pages to stuff things into a database. The final step creates a PDF document by querying the database and filling in form fields from the queries. Creating XML from the database and filling it by hand would work just as well and would have saved us from buying a 3rd party library.
Do you happen to know if there is any way to protect/encrypt the XFDF so that it can't be edited in Acrobat (granted, the encryption's been broken before, but it's a little safer this way)?
I'll have to check this out for our next version.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I am sure I am just not looking in the right place.
Can someone please point me in the direction of a good tutorial on using mock objects? I know what they are and why I need them, I just now need to know how to use them.
I am reading articles on unit testing here at CodeProject and Peter Provost's article touches on using mock objects, but the version of DotNetMock available for download as featured in the tutorial is different from what is in his article.
Marc Clifton mentions mock objects, but doesn't get into the guts of how to use them.
Where should I go from here?
Thanks,
- Craig
|
|
|
|
|
Just out of curiosity, I googled Peter Provost. The top of the list pointed to a log discussion where he stated he kept getting error no matter how he tried implementing DotNetMock and is relooking at the unit test issue.
I'm not sure what you are trying to do but building standalone test harnesses and running them against your objects prior to integration is pretty much standard fair. The typical approach we take is write a simple WinForm app with a 'Test It' button. It would then instantiate the object, pass data to it (usually what I provided as input to it), and displayed returned data (if applicable). It would be left without any exception catching so that if my object blew out of the water, I'd clearly see what I did to screw things up. If the harness is incorporated into the solution as an independant project, then I could also single step testing.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hello, i made this click event for a form, which stores and then divides a name in 3 seperate vars i.e. John C Sharp, to "John", "C", "Sharp".
here's the code:
private void btnParse_Click(object sender, System.EventArgs e)<br />
{<br />
string strFullName;<br />
string strFirstName;<br />
string strInitial;<br />
string strLastName;<br />
int intLocation1;<br />
int intLocation2;<br />
int intLength;<br />
<br />
strFullName = txtName.Text;<br />
<br />
intLength = strFullName.Length;<br />
intLocation1 = strFullName.IndexOf(" ");<br />
intLocation2 = strFullName.IndexOf(" ", intLocation1 + 1);<br />
<br />
strFirstName = strFullName.Substring(0,intLocation1);<br />
strInitial = strFullName.Substring(intLocation1 + 1);<br />
strLastName = strFullName.Substring(intLocation2 + 1);<br />
<br />
lblFirstName.Text = strFirstName;<br />
lblInitial.Text = strInitial;<br />
lblLastName.Text = strLastName;<br />
}
and when i enter no text or when i tried to trigger the text change event of the TextBox i got this error (it works just fine when i enter a full name)
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll<br />
<br />
Additional information: Length cannot be less than zero.
Thanks in advance (plz try to keep this simple as i am quite new to C#, thanks in advance )
|
|
|
|
|
intLocation1 = strFullName.IndexOf(" ");
In an empty strFullName the " " isn't found, so intLocation1 is -1.
strFirstName = strFullName.Substring(0,intLocation1);
For an empty strFullName this means Substring(0, -1) . What is a String with a negative length?
You should catch empty and short names:
<br />
String[] nameParts = strFullName.Split(' ');<br />
if(nameParts.Length == 3){<br />
strFirstName = nameParts[0];<br />
strInitial = nameParts[1];<br />
strLastName = nameParts[2];<br />
else if(nameParts.Length == 2){<br />
strFirstName = nameParts[0];<br />
strLastName = nameParts[1]; <br />
}else{<br />
MessageBox.Show("Please enter a full name.");<br />
}<br />
|
|
|
|