|
Hello,
VS 2008 SP1
I have created a application that I have installed on the user computer. However, I want the application to be self-updating. But I am not sure if this would really update the application.
The application will download all the files from the web server, and replace the files in the directory where the program as been installed to. The user will restart the application.
I am just want to be sure, because I can't replace the installed files with the updated ones. As the application will be running. So really the application cannot delete/replace itself.
So, I was thinking that I could download into another directory, if the program is installed in this directory 'program files/application/1.0.0' then I could download the files to 'program files/application/1.0.1'.
However, when the program restarts, how can it know that it has to execute from the 1.0.1 directory?
I can't use clickonce or the updater block for this.
Many thanks for any advice,
|
|
|
|
|
The first thing to spring to mind is the terrible practice of downloading the new files to a temp folder, then creating a run once on startup shortcut to a small app that copies the new files over the old ones and if necessary deleting the temp folder. Then prompting the user to reboot and doing it for them if they say OK.
But as I said it is a terrible practice, so I hope someone else has a better solution for you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
I use the following in a console app:
/* Not Visual Studio Resource File **********************************************************/
#ifdef APSTUDIO_INVOKED
#error This file is not editable by Microsoft Visual C++, use a text editor.
#endif
/* Header Files *****************************************************************************/
#include "Interface.h"
#include "Resources.h"
/* Icon Files *******************************************************************************/
IDI_C14_App ICON "Wrench.ico"
/* Version Resource *************************************************************************/
#define VER_FILEVERSION C14ROM_Major, C14ROM_Minor, C14ROM_Ver, C14ROM_Build
#define VER_FILEVERSION_STR C14ROM_Version
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "ROM Initialization Program"
#define VER_INTERNALNAME_STR "C14ROM"
#define VER_ORIGINALFILENAME_STR "C14ROM.exe"
#define VER_PARTNUMBER D5502
#define VER_PARTNUMBER_REV C14ROM_Build
#include "Version.rc"
Is there a way I can incorporate this into a VC# project without having to learn to do this from scratch? I can do small adjustments to the original file, but don't want to start from nothing.
Jer 29:11
|
|
|
|
|
Al_S wrote: Is there a way I can incorporate this into a VC# project without having to learn to do this from scratch?
Nope. It's not usable in it's current form. This file just sets up macros for the compiler. Whenever the compiler finds "VER_FILEVERSION" in the code, it gets replaced with "C14ROM_Major, C14ROM_Minor, C14ROM_Ver, C14ROM_Build". And so on down the line for each #define. You'd have to write equivilent C# code to do something similar. C# doesn't support macros like C/C++ does.
Oh, there's also an icon resource defined, which is easy enough to add to your project as long as you have the .ico file. You do have the .ico file, correct?
|
|
|
|
|
How do I translate this then? Is there a link to a tutorial that shows how to do this in C#? I've never had to do this in C#.NET and Win32 resources were usually done from scratch because they were small enough as shown.
I do have the icon file. That's the least of it
Jer 29:11
|
|
|
|
|
I just completed a file section on a BBS I just setup and I wanted to add an option to download files from it. From what I have read I need to find out how to Initialize a protocol in a BBS.
I'm trying to use FDSZ and GSZ and I get the same problem, 'No port Detected'
Both programs require a Fossel. x00 or bnu I have tried to use.
After researching this for the last 30 days. I find a lot if note on
the protocols them self's. Just nothing related to Initializing the bbs
Does any one now how to do this.
|
|
|
|
|
I am trying to write a small application for my domain that will delete files on the clients machine.
i have the delete code already also i have wrapped this around impersonation code so i can have admin creds
i am able to open file dialog and choose the txt file i want etc.. but after that im lost. I want to load the machine names i have listed in the machines.txt file and then hit search and it will go out and delete the file i have chosen.
for feed back i have a listview that is setup with grid lines and detail view with 2 columns machine and status
so once i load the machines.txt and i hit search button it will go through each machine name in the txt file go out to that pc remotely delete the file then will populate the listview with machine name and status saying deleted or file not found.
Thank you for your time!
-summey
|
|
|
|
|
ryan.summey wrote:
i am able to open file dialog and choose the txt file i want etc.. but after that im lost. I want to load the machine names i have listed in the machines.txt file and then hit search and it will go out and delete the file i have chosen.
I didn't get this line. You want to read machine name or you have stored machine name in machines.txt file?
Can you please give me some clarification on this
Hope to help you !
|
|
|
|
|
sorry for the confusion. In my program i have a menu and in that menu is file > open
click open and you can navigate to your machine.txt file or whatever as long as its .txt
once you click it hit ok i want it to load each machine name with in that .txt file
the reason for this is my applicatation deletes a file i have specified in the code. i dont want to do this manually entering in the machine names etc... I would like them to be all loaded then i hit search and it will go out and check each machine remotely delete the file if so show in the listview under status file deleted or file not found then move on to the next machine from the text file.
www.summeylabs.com/images/authplay.jpg
click that link and you can see what im talking about thank for your help.
|
|
|
|
|
Hey dude I think it will be easy if u try a database with 1 table ......... just my suggestion
|
|
|
|
|
I am on a domain is it possible to pull the machine names from Active directory? but my goal is to do this all at once i dont want to have to keep hitting search i want to load the names and hit search and it goes out if it dosnt find it keep moving it it does delete the file then keep moving till the end of the list.
|
|
|
|
|
What if u use the process to get the name of the machine ................... like
<br />
using System.Diagnostics;<br />
Process p=new Process();<br />
String name=p.MachineName;<br />
<br />
then use a database to write to it
|
|
|
|
|
I already know my machine names, i have them all in a machine.txt like this
lap-0101
lap-0102
ash-production
thats just 3 machines i have for testing ill have like 80. Think of it like this its like loading a password file into a password cracking prog.
it reads it line by line so for instance you would click open choose machine.txt then after it loads them all maybe a message box says all names loaded start search ok or cancle then click ok then it gos out to each machine deletes the file i have specified in my code and reports back in the listview all this works now if i manually type in the machine name into the text box if you look at this link you will see my application
www.summeylabs.com/images/authplay.jpg
but i am trying to automate the tast by supplying a file with all the names in it already.
i just dont know how to load each name one line at a time make do somthing else then once its done do it all over again untill end of file.
|
|
|
|
|
Hi,
Your question finally seems to have been resolved as how do I read the file. Is that correct? The following code would get the lines from the text file in a string array.
string[] machineNames = System.IO.File.ReadAllLines(filename);
After that it would be a simple matter to iterate through the individual names and perform a task with each one.
Alan.
|
|
|
|
|
I would use a for each statement to iterate through the individual names?
Thank you for your help
|
|
|
|
|
Yes that's right, foreach or just a plain for loop.
string[] machineNames = System.IO.File.ReadAllLines(filename);
foreach (string name in machineNames) {
DoTask(name);
}
for (int i = 0; i < machineNames.Length; i++) {
DoTask(machineNames[i]);
}
Alan.
|
|
|
|
|
AH thank you so much. Ill give this ago.
-Ryan
|
|
|
|
|
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "Load machines to search";
fdlg.InitialDirectory = @"c:\";
fdlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(fdlg.FileName, FileMode.Open, FileAccess.Read);
StreamReader m_streamReader = new StreamReader(fs);
the code above opens the dialog and im able to choose my txt file but how do i read the data to pip it all into the string
string[] machineNames = System.IO.File.ReadAllLines(filename);
foreach (string name in machineNames) {
DoTask(name);
}
thank you for your time and help.
|
|
|
|
|
Hey, what's MSDN for then! As I'm feeling generous, I'll give you a brief explanation anyway.
File.ReadAllLines is a convenience method that the framework supplies. It does the lot, that is, open the file, create a string array, read the lines into the array and then close the file. All you need to do is pass in the name of the selected file from the OpenFileDialog.
There are several other methods of this type that are useful when working with files that aren't too large. They are all in the System.IO.File class.... and that neatly brings me back to MSDN if you need to know any more.
Alan.
|
|
|
|
|
I am able to get them to load now to the listview but my question is once i have them loaded in the listview under machine colum i want to hit search and can the loop go through each listvew item perform the tast i want then on under status colum say file deleted if found if not file not found. then move on to the next mahine name untill the end. Check out the link below to see what im talking about.
www.summeylabs.com/images/prog.jpg
Thank you again for all your help.
|
|
|
|
|
Hi,
I think you might be better off deferring adding data to the listview until results arrive from the networked computers.
I'm guessing that your program already has code to handle one host name taken from the Host textbox, probably in the Search button click handler, and it should be possible to reuse that code. We refactor the code in the click handler like this:
private void SearchBtn_Click(object sender, EventArgs e) {
DoTask(HostTextBox.Text);
}
The DoTask method contains all the functionality to query and process the results from ONE networked machine. The advantage of refactoring is that you can now call the DoTask method for each host name in the list, code which could be placed into a menu click handler.
private void OpenFileMenuItem_Click(object sender, EventArgs e) {
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "Load machines to search";
fdlg.InitialDirectory = @"c:\";
fdlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK) {
string[] machineNames = System.IO.File.ReadAllLines(fdlg.FileName);
foreach (string hostname in machineNames) {
DoTask(hostname);
Application.DoEvents();
}
}
}
Now your program can handle a list of hosts, by reading a file, and it can still take a single name from the textbox.
The user interface (UI) can freeze during list processing because the loop prevents any UI updates until iteration has completed. The correct way to keep a UI active is to execute long duration tasks in a secondary thread, but to do that is another level of complexity which I don't think you're ready for just yet. I've inserted a call to Application.DoEvents() into the loop which is the poor man's way of keeping the UI responsive. In simple terms this allows keyboard or mouse input to be read, and the application windows to be redrawn on every iteration. Without it the UI would not update until the loop had ended.
Alan.
|
|
|
|
|
I'm trying to write a XmlDocument like so:
<br />
XmlDocument doc = new XmlDocument();<br />
<br />
<br />
StreamWriter s = new StreamWriter("output.xml");<br />
<br />
XmlTextWriter w = new XmlTextWriter(s);<br />
<br />
<br />
doc.WriteContentTo (w);<br />
<br />
w.Flush();<br />
<br />
s.Flush();<br />
s.WriteLine();<br />
s.Close();<br />
But it writes all the xml on one line. How do I make it put each node on its own line?
|
|
|
|
|
Could try the Formatting property of the XmlTextWriter.
|
|
|
|
|