Does the following work? Requires System.IO namespace foreach (string FileName in Directory.GetFiles(path, "file.ext")) { }
MNFlyer
Posts
-
Searching System Drive for a file -
Application server for Forms based solution ( not Web Based ) .Thanks for the clarification on this Luis, For my deployment I selected "The application is available online only". The app does run on the local PC but doesn't get installed there. If you remove the app on the server then it will not run on the local PC. If you make a change and re-publish then the remote users just close the app and re-open and it will launch the latest version.
-
Application server for Forms based solution ( not Web Based ) .Thanks for the clarification on this Luis, For my deployment I selected "The application is available online only". The app does run on the local PC but doesn't get installed there. If you remove the app on the server then it will not run on the local PC.
-
System.IO functions not working in Windows ServiceAfter some further searching I found that a service cannot use an existing mapped drive. It must create the map itself to work. This also has problems as a service may start prior log on an thus the network is not available. Looks like I may have to use my Windows App in the startup folder with a timer or filewatcher event.
-
Application server for Forms based solution ( not Web Based ) .I have created a similar application. I used the publish feature in VS2005 (not sure if exists in 2003) Look at the publish tab of the project properties. There should be a publish wizard that will allow you to publish the application directly to the server location. This helps get around a lot of the permission level problems. There is also an option to have a running application to check the server for updates. This can create problems if it is linked to your PC and not the server location. I disabled this for my application. This creates a deployment manifest method for launching an application. The end user just has to copy the shortcut created by the publish wizard to their desktop and it will launch a local version of the app from the server. Hope this helps.
-
Close MessageBox automaticlyOne way is to create your own form with an OnTimer event. The form can be just a label that you assign text to prior to showing it. Then the OnTimer event can call this.close();
-
System.IO functions not working in Windows ServiceI created a C# Windows Service to clean up files on some equipment PCs. Along with the service I created a configuration Windows App. that allows me to install, start, stop, uninstall the service and create an configuration XML file to change folder locations and such. Purpose: The service uses an OnTimer event to periodically check a folder for files. It then creates a backup copy on a network drive and deletes the local file. Problem: The following code does not work in the service but will work if performed from a button in the configuration app. The AddToFile function is working in the service as it just writes the string to a text file. The Service is configured to log on as a local system. Question: Why does this not work from within the service? //Code Section AddToFile(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + " Copying Reports to Network"); foreach (string sfi in Directory.GetFiles(SC.LocalReportFolder)) { FileInfo fi = new FileInfo(sfi); FileInfo fn; if (SC.CU.AppendMachineName) //Configuration file variable { //Adds the machine name to the report string nwname = fi.Name.Replace(fi.Extension, "_" + SC.MachineName + ".txt"); fn = fi.CopyTo(SC.CU.NetworkReportFolder + "\\" + nwname, true); } else { fn = fi.CopyTo(SC.CU.NetworkReportFolder + "\\" + SC.MachineName + "\\" + fi.Name, true); } fn.Refresh(); //If the copy was successful then delete the local file. if ((fn.Exists)&&(SC.CU.DeleteLocalReport)) { fi.Delete(); } } //End of Code