Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I'm aware there are answers to these questions existing already, however they more relate to windows and don't seem to be relevant to this question.
To start off, this application was made in C# and Xamarin.Forms.
What I'm trying to do is download three files into a folder on the computer. The folder does exist, so it can't be that.
Here's the code; (links have been removed)
WebClient web = new WebClient();
web.DownloadFile(new Uri(""), #"../../../ush/");
web.DownloadFile(new Uri(""), #"../../../ush/");
web.DownloadFile(new Uri(""), #"../../../ush/");
I get this while debugging;
Access to the path ' ' was denied.
If anyone knows a solution to this, let me know.
Thanks.
Turns out I wasn't giving the path to a file, just to a directory. Thanks to Sami Kuhmonen I was able to discover this.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm having trouble installing microsoft visual studio 2017. It loads to 100% then the setup fails. I get this error:
Package 'Microsoft.VisualStudio.MinShell.Msi,version=15.0.26711.1' failed to
install.
Can someone help me please?
Try to run installation as administrator. You need to have acces to folder C:\ProgramData\Microsoft\VisualStudio\Packages\.
Also check this article.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am having a problem deleting an image in my ASP.NET MVC 5 application.
I am creating a user management module of an application which requires images/photos of the staff uploaded. However, since the profile should be editable, the image should be made possible to be deleted. But when I try to delete the image, I find it difficult locating the correct path of the image. When I use
var fileToDelete = Path.Combine(Server.MapPath("~Content/photos/people/"),updatedStaff.Photo);
System.IO.File.Delete(fileToDelete);
or
`var fileToDelete = Server.MapPath("~Content/photos/people/"+updatedStaff.Photo);
System.IO.File.Delete(fileToDelete);`
The path returned for the image is wrong in that, it contains the controller and method in the path and so I cannot delete the image.
This is the error message I get:
Could not find a part of the path 'C:\Users\Josh\documents\visual studio 2015\Projects\EduPlus\EduPlus\staffmembers\edit\~Content\photos\people\de1e1cf0-d.jpg'
"staffmembers" is the controller and "edit" is the method
Please I will appreciate any assistance to figure out the problem.
Thank you
~/ is what you need to use before Content, not just ~ .
This should work perfectly fine.
var fileToDelete = Path.Combine(Server.MapPath("~/Content/photos/people"),
updatedStaff.Photo);
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
i have this piece of code
string [] ImgLocation =
Directory.GetFiles(#"Assets\Cards\Pack_Classic\", " *.png",
SearchOption.TopDirectoryOnly);
it's supposed to give me the location of all the image files inside the folder.However it doesn't work at all, it just gives me 0 strings. Why is that ?
The images location is : _Poker\Poker\bin\Debug\Assets\Cards\Pack_Classic
GetFiles needs an absolute file path in order to work in a reliable way. Get it from Reflection (through the Assembly class)
string exeDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string fullPath = Path.Combine(exeDir, #"Assets\Cards\Pack_Classic");
string[] ImgLocation = Directory.GetFiles(fullPath, "*.png", SearchOption.TopDirectoryOnly);
exeDir is your bin\Debug folder.
Note: GetFiles works also with relative paths starting at the current working directory. The problem is that you don't always know where that one is! It can be different from the directory where the executable resides.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm currently working on translating a VB.net program to C# and I'm having an issue with the process.
I'm trying to do the following with ConfigurationManager :
string myNumbers = ConfigurationManager.AppSettings("ClientNumbers");
Where ClientNumbers is a list<string> which works in VB.net but presents me with a "Method, delegate or event is expected" error in C#. I'm not sure why that is and I can't seem to find an answer using my Googling skills.
Thanks, in advance, for any assistance.
simply:
string myNumbers = ConfigurationManager.AppSetings["ClientNumber"];
you need to use the C# indexer which is a square bracket.
You misspelled the brackets
ConfigurationManager.AppSettings["ClientNumbers"];
Simply use this link for conversion http://www.developerfusion.com/tools/convert/vb-to-csharp/
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying to update a System.Data.SqlServerCe.3.5 database. The trick is that these databases are installed on client's PCs and we need them to upload the database to a web site, the web site then manages the data, then they download the updated database to the client. (Not sure if this is even possible)
Where is the "database" for a System.Data.SqlServerCe.3.5 based windows application? (In access it would be the *.mdb file)
I was able to find the *.sdf file in the roaming folder