|
I'm not sure I quite understand your question, but here it is:
if you need to start a process from your .Net application use System.Diagnostics.Process.Start
(string,string). So for a .doc file you would write:
System.Diagnostics.Process.Start("Word.exe","myFile.doc");
hope this helps
|
|
|
|
|
|
To open with the default program, without having to know what it is, use Process.Start("my.doc")
That will find word and use it. If the filename was an mp3, it would find the default media player, etc.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I am trying to install VS.NET 2003, and i am getting following error:
[08/20/06,09:46:42] setup.exe: [2] ISetupComponent::Pre/Post/Install() failed in ISetupManager::InstallManagerHelper()
[08/20/06,09:46:42] setup.exe: [2] Component error string not specified in ISetupManager::AddToActionResultCollection()
Anyone have idea how to resolve this?
Thanks,
Shafik
|
|
|
|
|
Hello
Maybe the problem is in your copy or something?!! Try installing it on another machine.
Regards
|
|
|
|
|
I tried to install it again, it worked fine.
Thanks.
|
|
|
|
|
Hi i have the following problem executing this code:
if(BrowseOpera2.PostedFile != null)
{
HttpPostedFile opera2 = BrowseOpera2.PostedFile;
if(opera2.ContentLength > 0)
{
if (System.IO.Path.GetExtension(opera2.FileName).ToLower() != ".jpg")
{
return null;
}
string strFileName1 = Path.GetFileName(BrowseOpera2.PostedFile.FileName);
/* Save the file on the server */
BrowseOpera2.PostedFile.SaveAs(Server.MapPath(strFileName1));
/* Create the email attachment with the uploaded file */
MailAttachment attach = new MailAttachment(Server.MapPath(strFileName1));
/* Attach the newly created email attachment */
retVal.Attachments.Add(attach);
/* Store the attach filename so we can delete it later */
attach2 = strFileName1;
}
else
{
return null;
}
}
else
{
return null;
}
Exception rised executing :
BrowseOpera2.PostedFile.SaveAs(Server.MapPath(strFileName1));
the exception is ACCESS DENIED, but on the IIS settings i both writing and reading are allowed
can someone help me please?
Marco
|
|
|
|
|
You have to allow write access to the user account that is used to run the ASP.NET code. This is usually the ASPNET or the IIS_WPG account.
---
b { font-weight: normal; }
|
|
|
|
|
But when i use the code above just to upload images to the server, everything is ok. only in this case i have exceptions...and of course i don't know why...it is taken from a copy & paste from another file i wrote. And of course everything works on the old file but i can't find the bug here...
|
|
|
|
|
You are storing the file at the same location on the server that it had on the client computer. This is very bad. It means:
:: Anyone can attempt to store a file anywhere on the server! Huge security hole!
:: The directory structure have to be the same on the server as on the client, or it doesn't work.
:: The ASP.NET user account has to have write access to the folder, or it won't work. As it can be any folder, you would have to grant write access to every folder, and that would only serve to widen the security hole.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have a C# project which imports a .csv file, however some of the characters in the file are square characters. These characters mean that when I write the output to a text file I get a newline where the square characters were. My question is how can I remove these square characters? If I wanted to remove say the character value "s" I could write:
String holder = "susan";
char[] myChar = {'s'};
String newString = holder.Trim(myChar);
Output = "uan"
The problem is I don't know how to remove the square character because it is not a conventional ASCII character.
Any help is much appreciated.
Thanks
James
|
|
|
|
|
Not clear for me what you actually try to do, but hope short info will lead you to the solution.
Unix environments use "\n" for newline, while Windows uses combination "\r\n".
While in C you can use "\n" to indicate newline for both Unix & Windows environments,
in c# you should specify explicitly what you want that is "\r\n" for Windows, and even better you should use Environment.NewLine
SO, my guess is your CVS file is from Unix like environment so you should replace single "\n"s with "\r\n" OR you should correct the code which generates .CVS file to use correct new line value.
Vitaliy Tsvayer
Tikle
|
|
|
|
|
Hello
How did you display your CSV file to view the square char?? Using the notepad maybe?
James19841984 wrote: The problem is I don't know how to remove the square character because it is not a conventional ASCII character.
AFAIK it should have a code no matter what!! Try reading a known file char by char until you reach this char's position, then display its code in a messagebox or something.
Another thing, open a CSV file with an editor -eg notepad-, copy the square char -if you know that ALL squares are the same char. Sometimes the notepade jst display a square for several chars that it doesn't understand. When you copy the char, paste it into your code -ie. hardcode it-
Also use:
char Sq;
While(MyString.IndexOf(Sq) != -1)
MyString.Remove(MyString.IndexOf(Sq), 1);
Regards
|
|
|
|
|
Hi,
i also faced same problem some days back.
but i found the ans.
you can use '\r\n' for that newline character.
here is the example
string strTemp="Store Your String Here!";
strTemp.Replace("\r\n","");
hope this works.
Nitin...
|
|
|
|
|
Thanks for the replys.
I have tried "\n", environment.newline etc but none of them seem to work. The reason for this I believe is because C# doesn't recognise the character as a newline, but simply a character in the shape of a square.
When I copy and paste the symbol into a .net environment it just pastes a newline (ie, like it would I key return). The symbol will have a character code, but I can't seem to find out what it is. I believe if I have that I can remove these characters.
Any other ideas or knowledge about the character code would be much appreciated.
Regards
James
|
|
|
|
|
James19841984 wrote: The reason for this I believe is because C# doesn't recognise the character as a newline, but simply a character in the shape of a square.
C# recognises no such thing. It will be the text renerizer that displays the square. Usually a square is rendered in place of a character that has no shape defined for the font used.
C# recognises characters based solely on their code.
James19841984 wrote: When I copy and paste the symbol into a .net environment it just pastes a newline (ie, like it would I key return).
Perhaps the renderize is being forced to render a newline.
|
|
|
|
|
Hello
There is another approach, yet I don't prefer it. Try to exclude any character outside the range of the ascii code of letters, digits, and any other symbol that you allow. If the character is outside that range delete it from your CSV string. This way you'd make sure only the things you want will survive.
Another approach. Read the file using HEX editor. Find the value of the byte(s) representing the character that is bugging you -or your program -. Anyway. When you find the byte(s) value, read your file as an array of bytes and remove the "square" chars by their byte values.
I don't think there are more approaches. If this doesn't work, call NASA
Regards
|
|
|
|
|
Hey,
I'm writing a class using sockets. I am sending using the main thread and listening with a worker thread. When a message is recieved by the worker an event is raised. I would like these events to be raised on the main thread. The only solution I can come up with is to use the invoke method of a form, but as I am not using any forms I was wondering if there is another method I could use?
Any suggestions?
Many Thanks
Tom
|
|
|
|
|
Hello
theonewithtom wrote: I would like these events to be raised on the main thread
You stil can do something like that, but why?!! Why not using Asynchronous sockets?
Search MSDN for BeginAccept() method
Regards
|
|
|
|
|
Thanks, I've been having a bit of a problem with the async read method, so is it possible to do it without using this?
Many Thanks
Tom
|
|
|
|
|
Hello
Of course you can using a single thread. Actually what happens behind the scene is that the asynchronous call makes an anonymous worker thread for you that will carry the action. When that thead receives anything it will call the Callback method that you will provide as a delegate.
Take a look t this code, copied from MSDN:
IPHostEntry lipa = Dns.Resolve("host.contoso.com");
IPEndPoint lep = new IPEndPoint(lipa.AddressList[0], 11000);
Socket s = new Socket(lep.Address.AddressFamily,
SocketType.Stream,
ProtocolType.Tcp);
try{
s.Bind(lep);
s.Listen(1000);
while(true){
allDone.Reset();
Console.WriteLine("Waiting for a connection...");
s.BeginAccept(new AsyncCallback(Async_Send_Receive.Listen_Callback), s);
allDone.WaitOne();
}
}
catch (Exception e){
Console.WriteLine(e.ToString());
}
All you have to do is to provide the callback method.
Regards
-- modified at 16:16 Sunday 20th August, 2006
Sorry, I just noticed you said "async" not "sync". What's exactly your problem with the above approach??
Regards
|
|
|
|
|
Maybe my question is simpler than I first thought
> When that thead receives anything it will call the Callback method that you will provide as a delegate.
Do you mean it is possible to call a delegate from a worker thread that will execute on the main thread?
Many Thanks
Tom
|
|
|
|
|
Hello
theonewithtom wrote: call a delegate from a worker thread that will execute on the main thread?
No! You don't bother yourself with multithreading. You just make a method to handle the data -called callback method- which will be excuted on the main thread. Once you want to listen call the BeginAccept() or BeginReceive -accroding to how you want to handle your sockets-, and all the listening and reading time is done on another thread invisible to you. You don't make any threads. It will be made for you and you can't access it. Everything you write will be excuted on the main thread -which if you don't handle properly may make your UI freezes-.
Regards
|
|
|
|
|
Okay, I'll go through why I think I need multithreading. My listener code is below:
<br />
private void run() {<br />
<br />
NetworkStream ns = new NetworkStream(clientSocket);<br />
BinaryFormatter bf = new BinaryFormatter();<br />
<br />
while (true) {<br />
<br />
Message m = bf.Deserialize(ns);<br />
<br />
messageRecieved(this, m);<br />
}<br />
<br />
}<br />
As far as I can tell, it is not possible to do the deserialize and use the async read methods.
Any thoughts?
Many Thanks
Tom
|
|
|
|
|
Hello
Well if the asynchronous method troubles you and you want to multithread -The way I like BTW-. Then you should use Invoke() . Have a look
delegate void MessageReceivedDel(Message m);
private void run() {
NetworkStream ns = new NetworkStream(clientSocket);
BinaryFormatter bf = new BinaryFormatter();
MessageReceivedDel messageRecieved = new MessageReceivedDel(MessageReceivedMethod);
while (true) {
Message m = bf.Deserialize(ns);
messasgeReceived(m);
}
}
private void MessageReceivedMethod(Message m)
{
}
Remember that MessageReceivedMethod is a member method of you main form class.
Regards
|
|
|
|