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);
Related
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.
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 6 years ago.
Improve this question
Code that did work now all of a suddent not working due to not returning response of HttpRequest on partial content C# UWPDropbox, Google Drive & Onedrive.
I have a feeling that a Visual Studio or Windows 10 SDK upgrade caused this or maybe .Net has a change I am not aware of....
Has anyone else faced a similar issue?
Awaiter deadlock with Task return, solved with out parameters
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 just debugged my latest application, which reads content of txt files and shows them in a DataGrid. Unfortunately, if I debug my script, it is just shown in the Windows Taskbar with the preview of the application, but it does not display on screen. I cannot see it. Can you tell me why?
It is the only application. All my other applications work well.
EDIT: I use own settings for displaying my window. The window position was set to -32000 and -32000. That was my fault. Thank you!
Did you set your forms WindowsState to Minimized , maybe ?
If so change it back to Normal and it will show up.
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
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 9 years ago.
Improve this question
I have an assembly data project in my solution that is being consumed by a different project. The data project contains three different edmx entries.
I'm calling a function import in one, but inside the edmx.cs I'm receiving an error on the calling line:
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction
((IObjectContextAdapter)this).ObjectContext
is returning the type of a different context entirely! Thus it cannot find the function I'm calling.
Has anyone seen this behavior before? I don't know why it would be in one context and yet return the other type when the ObjextContext is checked.
A foolish mistake on my part. My connection string in the consuming project was pointing to the wrong csdl. The code compiles fine, you can update from the model perfectly, but it will break at runtime when the consuming project's config is used. Even though you can trace into the edmx.cs file for your data project, it will cast to the other model on the execution line.