C
C#CrosRoad95

❔ Reading file from the folder where .csproj is

How can i read files from folder where .csproj is? just like webapps allow to do, they do not copy files
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
don't working
C
CrosRoad95511d ago
for simplicity let's say they are .html but i need to change them at runtime for easier debugging folder would looks like this:
index.html // "copy to output directory": "do not copy"
project.csproj
program.cs // File.ReadAllText("index.html")
index.html // "copy to output directory": "do not copy"
project.csproj
program.cs // File.ReadAllText("index.html")
because i want to at runtime change content and be able to refresh otherwise i have to open some /bin/net7/ folder to edit them what is really invonvinient
W
WhiteBlackGoose511d ago
so you want to change an html file?
C
CrosRoad95511d ago
yes, at runtime but then i need to copy file again back just tell me how can i do this 😄 if idea end up being wrong, i will change later i need it only for debugging i assume i can set "current directory" to be ../../../ or smth like this ^ i will do this only for some functions, they will in debug seek for files in ../../../ folder Environment.CurrentDirectory - is ending always /bin/debug/net7/ ? sometimes seen it is slightly different i mean, i need to go 3 folders up, hope it doesn't change though there is some magic global variable holding path of .csproj 😄 one more question, how the hell can i configure "CopyToOutputDirectory" to copy entire folder?
<None Update="myFiles\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="myFiles\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
??? yea, recursive does it copy files only when they has changed? it means it may behave better with large files right now it's only 20KB in total, but i assume as number and size will growth, i will need to wait longer to start debugging
<None Update="MyFiles\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="MyFiles\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
right? as i said, i will create some "MyFilesProvider" which holds root directory, in debug it will be "../../../", in release the current directory i'm not doing standard web or console app 😛
A
Accord510d ago
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.
Want results from more Discord servers?
Add your server
More Posts
✅ Interoperability between incompatible typesHi! I'm trying to pass a class back-and-forth from C# to CPP. This class contains some members that ❔ Set item to null inside a listHey! I am trying to remove some items from a JSON object (created like `var model = new ObjectModel{Refactoring long if statement that checks for user rolesHi, I'm trying to find a cleaner way of refactoring this if code block that checks for each user rol❔ IEnumerable and dependency injectionif i want to loop enumerable from DI multiple times ``` var foos = services.GetRequiredService<IEnum❔ How did you learn . NET ?Books /youtube/udemy /other courses, what resources made you learn .NET to use as your job as web de✅ Is it possible to disable these properties on EF6? Web API 2 project, multi-layered, NF472SCENARIO - Solution type is NET Framework 4.7.2 (it is, what it is). - I have this project, I'm cons✅ This EntityFramework query can not be translated for SQLiteThe issue lies within `Intersect`. The point of the query is to fetch the current user, and to popul✅ Detect Network RequestI want make service that detect all connection to specific domain or ip? And if this request contain❔ CORS errorHello, I have Cors error on my project. I add Addpolicy in my configureServices and also add app.Us❔ Ambiguities? How?Idk how i can resolve this i don't see the problem✅ How can I get rid of this annoying pointer thing in the first row, datagridview winforms^✅ How can I use a row header of a datagridview to display the row number instead of being empty?^✅ How can i properly display this datagridviewHow can i get rid of the row select thing on the left (just white space)✅ I am trying to output a 2D array to a datagridview, but it is not outputting correctlyIt is saying System.Int32[]✅ Task not returning and stopping programHey, I am currently trying to start one task for every string in the list, but this isn't working an❔ DbContextCan i use this in a non-asp area like for example, a simple program to make few tables using DbSet✅ The specified deps.json does not exist while scaffolding DBI am going through a tutorial to create a Web API app with ASP.NET6 and MySql. I wanted to scaffold ❔ C sharp object reference errorI am trying to reference an object that I'm displaying on PageHeader.xaml and I keep getting this erInteroperability issues (PInvoke)Hi! I'm calling a native CPP library and retrieving a struct by reference which returns a struct con❔ SKIA SHARP PROBLEMError: ```cmd Dec 02 16:05:22 mourashop shopmoura-api-app[3847595]: Unhandled exception. System.Argu