I have a website that has a linkbutton that opens a game :
Process game= new Process();
game.StartInfo.FileName = HttpContext.Current.Request.MapPath("~/iFarkle.exe");
game.StartInfo.UserName = Session["Username"].ToString();
game.StartInfo.UseShellExecute = false;
game.Start();
How do I use the StartInfo.UserName? (it doesn't work right now, it stays I entered bad data)(works without the StartInfo.UserNam开发者_StackOverflow社区e
If you want the exe to run on the users computer, you can either:
Provide a direct link to the exe file (and make sure your server is configured to serve .exe files), or,
Stream the contents of the file back in the response (having made sure to set the Response ContentType to a suitable type (I think application/x-msdownload would work)).
I'd only do the second if I was going to, for example, perform some additional checks before allowing the download. Of course, as soon as the user has downloaded the exe, they'll be free to do with it whatever they please.
Also note that this will only work if the exe doesn't have any other DLLs it relies on (except DLLs which are safe to assume will already be accessible on the client machine).
精彩评论