Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a windows form application which works with data sets that are text files. I tested the application on other systems and it works, properly.But for running the application the data sets must copy into C Drive directly. Is there any solution for running the application without copying the data sets into C Drive or any directory?
The form of my script to read the dataset?
StreamReader fileitem = new StreamReader("c:\\dataset.txt");
I hope to get your detailed comments.
It looks like you are looking for System.Windows.Forms.Application.StartupPath. Source
That is an environment variable, which gives you the path for where your exe file started. This means, if you run your app from a USB drive G:\MyApp. You could use:
StreamReader fileitem = new StreamReader(Path.Combine(Application.StartupPath, "dataset.txt"));
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am using this code
axWindowsMediaPlayer1.URL = #"c:\myvideo.avi";
but when the video file containing folder changed this code is not working.i need to set an permanent URL even though the file containing folder is changed.
You can’t find the file if it’s location was changed. Imagine if the user moved it to another drive or permanently deleted it - what would you do then?
If you’re changing folder within your application then of course you can track where the file was placed and correspondingly change the path. But if the path was changed outside of your app you can’t do anything with it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
rom what i know i can either save it in a database or through file io. The data has to be locally stored and i don't want data in datagrid view .
If i store the data through file handling then how can in store data in the directory where the software will be installed. I have tried service based database(.mdf format) and can't get it work. I need it for project. Thanks in advance.
To create files, you will be using the System.IO.File namespace. This gives you access to methods such as Create(), CreateText(), WriteAllBytes(). Which method you use will depend on what type of data you are using.
To save the file in your application directory, you can get the path using AppDomain.BaseDirectory
So for example if you're storing plain text, you could do something similar to
public static void WriteSomeText(string text)
{
string path = Path.Combine(AppDomain.BaseDirectory, "mytextfile.txt");
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(text);
}
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I just want to add the external file in C# desktop application to store the queries. In that I want to add each query as string. And will take out of the file when needed.
1) How to add external file in C# desktop application.
2) How can i access the file from my application?
Thanks in advance.
There are a couple of options:
Add the file to the project and set the "Copy to Output Folder" option. Then make sure you deploy the file with the application.
Make the file an embedded resource. Then it becomes part of the exe and you don't have to deal with a separate file for deployment.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm having trouble creating an installation program for my Winforms application. I am using the Windows Installer and the publish function. It creates a nice setup program. After I run the setup on a client machine, I want to update the App.config file to point to a different database than was used for the setup. I have this setting in the app.config file. However, I am not able to update the app.config file on the client's machine. Temporarily, I am creating a new build when I want to change the database that the application points to.
Duplicate of...
Setup App.Config As Custom Action in Setup Project
?
The answer looks good...
http://raquila.com/software/configure-app-config-application-settings-during-msi-install/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
hi i am creating a c# application that monitor the files that has been copied , the aim of program is to alert user that there is a file has been copied , i know the file system watcher class , but it has only 4 events , change or create or delete or rename , is there a way to know if file has been copied in or out of system ?
When a file is copied into the system you will also get a change or create event. But if it is simply accessed (which is what happens when it is copied) FileSystemWatcher is of no use.
You can use Auditing file and folder access feature of Windows.
The task makes no sense. First of all, there's no "copy" operation on the OS level. Copy is a sequence of open/read/close (source) + create/write/close (dest) operations. Now, even if such operation existed (eg. Explorer has such concept), what about archiving the file and then copying out the archive?