Click here to Skip to main content
15,903,724 members
Home / Discussions / C#
   

C#

 
GeneralRe: about text editor. only text editor, not server or .... Pin
Bigdeak29-Aug-10 23:35
Bigdeak29-Aug-10 23:35 
GeneralRe: about text editor. only text editor, not server or .... Pin
Fred 3431-Aug-10 2:34
Fred 3431-Aug-10 2:34 
AnswerRepost PinPopular
Pete O'Hanlon30-Aug-10 0:35
mvePete O'Hanlon30-Aug-10 0:35 
AnswerRe: about text editor. only text editor, not server or .... [modified] Pin
PIEBALDconsult30-Aug-10 3:16
mvePIEBALDconsult30-Aug-10 3:16 
AnswerRe: about text editor. only text editor, not server or .... Pin
Eddy Vluggen30-Aug-10 8:54
professionalEddy Vluggen30-Aug-10 8:54 
QuestionParallel and Thread running some mission ( code attached ) Pin
Yanshof29-Aug-10 22:49
Yanshof29-Aug-10 22:49 
AnswerMessage Closed Pin
29-Aug-10 23:26
stancrm29-Aug-10 23:26 
GeneralRe: Parallel and Thread running some mission ( code attached ) Pin
Yanshof29-Aug-10 23:29
Yanshof29-Aug-10 23:29 
GeneralRe: Parallel and Thread running some mission ( code attached ) Pin
DaveyM6929-Aug-10 23:50
professionalDaveyM6929-Aug-10 23:50 
GeneralRe: Parallel and Thread running some mission ( code attached ) Pin
Yanshof29-Aug-10 23:55
Yanshof29-Aug-10 23:55 
GeneralRe: Parallel and Thread running some mission ( code attached ) Pin
DaveyM6930-Aug-10 0:23
professionalDaveyM6930-Aug-10 0:23 
GeneralRe: Parallel and Thread running some mission ( code attached ) Pin
Yanshof30-Aug-10 0:50
Yanshof30-Aug-10 0:50 
QuestionAutomatically Install Updated Application Version Pin
PDTUM29-Aug-10 12:34
PDTUM29-Aug-10 12:34 
AnswerRe: Automatically Install Updated Application Version Pin
Luc Pattyn29-Aug-10 12:59
sitebuilderLuc Pattyn29-Aug-10 12:59 
GeneralRe: Automatically Install Updated Application Version Pin
PDTUM29-Aug-10 13:23
PDTUM29-Aug-10 13:23 
GeneralRe: Automatically Install Updated Application Version Pin
Luc Pattyn29-Aug-10 13:42
sitebuilderLuc Pattyn29-Aug-10 13:42 
GeneralRe: Automatically Install Updated Application Version Pin
phil.o29-Aug-10 21:21
professionalphil.o29-Aug-10 21:21 
GeneralRe: Automatically Install Updated Application Version Pin
PDTUM30-Aug-10 3:47
PDTUM30-Aug-10 3:47 
GeneralRe: Automatically Install Updated Application Version Pin
phil.o30-Aug-10 6:02
professionalphil.o30-Aug-10 6:02 
AnswerRe: Automatically Install Updated Application Version [modified] Pin
Sunil G30-Aug-10 3:11
Sunil G30-Aug-10 3:11 
GeneralRe: Automatically Install Updated Application Version Pin
PDTUM30-Aug-10 3:56
PDTUM30-Aug-10 3:56 
GeneralRe: Automatically Install Updated Application Version Pin
Sunil G30-Aug-10 18:13
Sunil G30-Aug-10 18:13 
AnswerRe: Automatically Install Updated Application Version Pin
Matthew Klein30-Aug-10 14:38
Matthew Klein30-Aug-10 14:38 
I use the following for my one EXE updating solution. It may not follow best practices, but it works.

The idea is that you rename your current exe to a temp file, rename your new exe to your "normal" filename, then restart the process. You can rename the exe while its running, but you don't delete it. Instaed, you delete the "old" exe during your next update (or after the restart) and that way its no longer loaded in memory.

void UpdateAndRestart()
{
    //Assumes you have already downloaded new exe to myNewExeLoc
    string myNewExeLoc = @"C:\My Folder\myNewExe.new";
    string myCurrentExe = System.Reflection.Assembly.GetExecutingAssembly().Location;
    string myBakExe = myCurrentExe + ".bak";

    if (System.IO.File.Exists(myBakExe))
        System.IO.File.Delete(myBakExe);

    System.IO.File.Move(myCurrentExe, myBakExe);
    System.IO.File.Move(myNewExeLoc, myCurrentExe);

    System.Diagnostics.Process newP = new System.Diagnostics.Process();
    newP.StartInfo.FileName = myCurrentExe;
    newP.StartInfo.Arguments = "/updated" //or whatever arguments you want to pass (not required)
    newP.Start();

    System.Environment.Exit(0);
}


Edit:
I should note that I use a System.Threading.Mutex to make sure that only one version of my program is running at a time, so I can be sure that when I delete the old filename that there isn't still a version loaded in memory. I also check for the "/updated" argument on startup and deconflict any issues with the Mutex if the other version still hasn't unloaded (to mitigate race-condition errors).
GeneralRe: Automatically Install Updated Application Version Pin
Luc Pattyn30-Aug-10 14:54
sitebuilderLuc Pattyn30-Aug-10 14:54 
GeneralRe: Automatically Install Updated Application Version Pin
Chuck O'Toole30-Aug-10 16:16
Chuck O'Toole30-Aug-10 16:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.