❔ how to get path to folder?
I'd like to create folder in another csproj, how can I do it?
Now I only can do this using full path:
where
Tools.ReportDesigner
is another csproj in sln9 Replies
For folders you use one of the
Directory.CreateDirectory
methods: https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory?view=net-7.0Directory.CreateDirectory Method (System.IO)
Creates all the directories in a specified path.
I need a path where folder will be created
thats why I asked “how to get path”
Use
Directory.GetDirectory
methods :https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.getdirectories?view=net-7.0Directory.GetDirectories Method (System.IO)
Returns the names of subdirectories that meet specified criteria.
I need to pass a path to this method
and I dont have it
I’d like to get path for folder in another csproj
So how do you determine which csproj to search for?
sln
first project
second project
im in first and wanna create folder in second
So typically solutions are stored under the "C:" drive, so you can start your directory search there. Then use the
searchPattern
part of GetDirectories
to filter what directory you are looking for.
You could also start with Directory.GetCurrentDirectory()
and then use Directory.GetParentDirectory()
to navigate up from where your app is, searching the directory for the other project name. If you don't find it, get the next parent until there's no more parents.Path.GetDirectoryName()?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.