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 11 years ago.
how do I get the path of the project?
i want to assign a string with the path of the folder of the project.
lets say, the folder of my project (in C#) is E:\projects\something
(in folder something, I have the .sln file and all the source codes and also a folder pictures, and in some function I want to assign a string to the path of the project's folder for after it use fhe files in pictures... what I need is a function retorning the path of the project.
string s=project_path;
private void button1_Click(object sender, System.EventArgs e)
{
string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
MessageBox.Show( path );
}
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 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.
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.
How to navigate between one project file to another in visual studio 2010 for windows phone so that we can use xaml files or use other cs files in each other.........
This is what you need to do:
private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));
}
You can find in detail from here http://msdn.microsoft.com/library/windows/apps/ff626521(v=vs.105).aspx
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 11 years ago.
I am trying to save an xml file to C:\Program file\MyApplicationFolder\my.xml, but I am receving an access denied error.
How can I save the file successfully?
Please help me! Here is my code
using(XmlWritter write=XmlWritter.Create(Application.StartUppath){write.WriteStartDocument();
write.WriteStartElement("Setting");
write.WriteElementString("Username", name);
write.WriteElementString("Password", psw);
write.WriteEndElement();
write.WriteEndDocument();
C:\Program Files is a restricted folder. Only administrators can modify the contents of this folder.
Use this code to generate a path:
FileName = Path.Combine( _
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), _
"MyApplicationFolder\My.xml" _
)
This saves to a folder the user has access to:
C:\Users\<username>\AppData\Roaming\MyApplicationFolder\My.xml
Try saving to the per-user Application Data directory instead.