It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm creating a program in C# WPF that allows the user to manually input a directory in a textbox so that the program will retrieve and list the files in the specified directory into another textbox.
My problem is that I don't know how to assign the value from a textbox to the directory path.
I'm able to specify the directory manually in the code however I'm not sure how to assign the directory path from a textbox...
Any ideas?
My code when a button is clicked is as follows:
// Makes a reference to a directory.
DirectoryInfo di = new DirectoryInfo(#"C:\");
DirectoryInfo di = new DirectoryInfo(textbox.Text);
That should work.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
How to walk a directory application project ASP.NET MVC 3 ?
For example: I must find one file in derectory MyApp.WebUI/controls
You could use the Directory.EnumerateFiles method. Or if you already know the name of the file you could directly access this file. In order to calculate the absolute path to this directory/file you should use the Server.MapPath method:
var location = Server.MapPath("~/MyApp.WebUI/controls");
var files = Directory.EnumerateFiles(location);
...
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Hi I am trying to delete files from a directory.It is able to delete the first file ,but after that
it is not able to delete other files.It is showing error message "the process cannot access the file as it used by other process.
My code for deleting is
foreach(FileInfo file in files)
{
file.delete()
}
Please help
The operating system will not let you delete a file in use by another process.
Use this tool to find out what process is accessing the files you are trying to delete:
Process Explorer v15.3
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm trying to access a file inside my project.
So I would create a new folder called Files and inside that folder contains various HTML files.
Is there anyway that I can access those files by going to "Program/Files/file.html" or similar.
Do you mean something like this?
using System.IO;
...
string folderPath = AppDomain.CurrentDomain.BaseDirectory; // or whatever folder you want to load..
foreach (string file in Directory.EnumerateFiles(folderPath, "*.html"))
{
string contents = File.ReadAllText(file);
}
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I've made a program using C# and I want know how to associate file which output to open by using this program.
this program made files with an extension .fct I want this files with that extension open in my program when it double clicked
You might want to look into this: http://mel-green.com/2009/04/c-set-file-type-association/
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
i want to add file(photo) to fileupload control in the c#(code behind)
thanks
You can't do that.
The only possible way to get a file path into an upload control is for the user to select a file using the file selection dialog.
For security reasons you can't force a file name into the control, neither in the html code, nor using Javascript. As you can't specify it in the html, there is naturally no property for that in the server control that generates the html either.
Well, then you just add a click event to the button on the fileupload control... something similar to this:
fileupload.PostedFile.SaveAs(Server.MapPath() + fileupload.PostedFile.FileName);