I want to access the path of the folder that my published application has been run from.
Everything I can find says use Application.StartupPath(), but this doesn't work.
I wrote a simple program to display these, published to a single standalone file and then ran it from the directory C:\Users\jerem\Downloads\split.
This is what i got:
Application.StartupPath = "C:\Users\jerem\AppData\Local\Temp\.net\getlaunchdir\jvi1ji54.zau\"
Application.ExecutablePath = "C:\Users\jerem\AppData\Local\Temp\.net\getlaunchdir\jvi1ji54.zau\getlaunchdir.dll"
It seems that running the .exe file creates a temp folder with a load of files in it that are then run. Fine, but it returns the "wrong" results for StartupPath - i.e. not what I want.
How do I fix this?
Thanks
** image of publish settings added as requested by Caius Jard.
picture of publish settings
I'm not sure how you get your image showing application.startuppath as C:\temp\ - that looks like a debug mode shot and my problem only occurs while running the published program.
I suspect you published it with ClickOnce? If you publish it with Folder, it ought to behave as you expect
And when run:
Possibly might be what you are looking for:
Private uriBuilder As New UriBuilder(Reflection.Assembly.GetExecutingAssembly().CodeBase)
Public FullAssemblyPath As String = Uri.UnescapeDataString(uriBuilder.Path)
Public ExeDirectory As String = IO.Path.GetDirectoryName(FullAssemblyPath)
Related
My game relies on a resource folder Located in C's Program Files called 'resources' using pretty basic code to make up the front end of the game
Public Module getItem
Public Item = Image.FromFile("C:\Program Files\GameName\resources\ItemName.gif")
End Module
to get a picture or video, or text as such I'm pulling the request as such for an update
Dim req As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("dropbox link to folder")
Dim res As System.Net.HttpWebResponse = request.GetResponse()
Dim ss As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim version As String = ss.ReadToEnd()
so it knows to update but grabbing the entire contents and redownloading it if there's an update in the folder is where im not understanding how i would want to do this in an simple fashion without exhausting memory.
Im familiar with
webclient.DownloadFile("database", FolderName)
This being a method in which you get a .zip folder, which requires unpacking and locating and replacing files and it just feels inefficient.
But if i only make a few changes is there a way to recognize the change and ONLY download the new images that are needed to that resource file without re-downloading everything (300 MB) or if it need be; to re-download everything (replace i suppose), is there a way to unpack the dropbox folder contents that's online into being a download via just picture into the file? I've given thought to the idea of possibly isolating them to a new folder named 'updated content' that just pulls the new pictures/music/videos out each download. Would that be a viable solution? the idea is to throw the new content in the folder to be read. I can just have the EXE updated and with that comes the new code to pull the new content by X method. Doesn't anyone know of a easier way of possibly doing this, i'd like to stick to Dropbox if at all possible.
Any help or advice is greatly appreciated, Thank you.
Central Notes: 'Dropbox Folder Download'
I want to make a simple .exe application in vb.net. The application wont have an installation just pure run on .exe file .
Application has one form and two pictures. When i set the option on image to build action - compile
Unable to open module file 'C:\Users\t3cho\documents\visual studio 2013\Projects\Apps\Apps\Resources\power.png': System Error &H80041feb&
Is there any other way to make an .exe file with images without installation or additional folders.
The easiest way to include images (and other types of resources) into the application is to right-click the project, go to the "Resources"-Tab and add the image there. You can change its name to e.g. MyEmbeddedImage and access it like this
Dim img As Image = Properties.Resources.MyEmbeddedImage
or
Dim img As Image = My.Resources.MyEmbeddedImage
This automatically sets the Build Action to None.
Note: This approach is type-safe and you will get errors at compile time, if the image is missing.
See: My.Resources Object and How to: Add or Remove Resources
If you still want to embed the image "manually", you must set the Build Action to Embedded Resource and access it as #Icemanind describes.
Yes. It's called embedded resources. Set your image's Build Action to Embedded Resource. You can then get the image at runtime like so:
Try
_assembly = [Assembly].GetExecutingAssembly()
_imageStream = _assembly.GetManifestResourceStream("MyNameSpace.MyImage.png")
' Do something with _imageStream
Catch ex As Exception
' Resource not found or something went wrong
End Try
I'm trying to upload files in Meteor using this great script. I modified the event to handle multiple files, like this:
'click #saver': function(ev) {
$.each( $(".fileuploader"), function (index, item) {
if(item.files.length > 0) {
Meteor.saveFile(item.files[0], item.files[0].name);
}
})
}
Everything else is exactly the same as in the Gist (see link to script, above).
The upload shows no errors and the page reloads after the public folder is changed, but most of the files uploaded to the public folder show up as empty, (i.e. they are 0kb in size). There seems to be no pattern. Sometimes all files are empty, sometimes only a couple, and in no predictable order. The console sometimes logs correctly, and other times doesn't. Any thoughts?
Thanks, as always, for your considered advice.
db
It's not that easy at this moment. Files in public dir are managed by Meteor. Therefore, whenever contents of that directory change, the server reloads itself - terminating the file save you've been inside.
The solution is to put files in a place Meteor does not care about: hidden folder (.name), ignored folder (name~), or folder outside of Meteor directory.
Then you'll need to serve those files by hand. See this answer for a snippet:
Dynamically insert files into meteor public folder without hiding it
I am having serious trouble opening, actually finding, any kind of Video Files with IntelliJ.
The files are in a folder called "data" in my Project Directory. In the Project Structure Settings I made sure the Folder is recognized as Source. Then I even declared my *.mov & *.mp4 files as new Filetypes.
But still when I am trying to load the video like:
mov = new GSMovie(p, "camel.mov"); or even
mov = new GSMovie(p, "data/camel.mov");
It doesn't find it.
I also tried different libarays.
and keep getting:
File camel.mov does not exist. Please check location.
Actually I just found out that it is looking in the IDEA app binary itself.
The JMC-Video for Processing:
Media unavailable: file:/Applications/IntelliJ%20IDEA%2010%20CE.app/bin/data/look321.mp4
It works if I copy my files now there, but this can't be right.
It feels like I am doing something fundamentaly wrong, but I just can't see it.
thanx, for any help.
You should add *.mp4 and *.mov to Settings|Compiler|Resource Patterns
Set the working directory to the project root in the Run/Debug configuration.
i published an application in vb.net. the user will be able to install the application anywhere they choose on the computer (or perhaps not anywhere they choose but where ever the default location is). how can i programmatically get the location where the user installed the application? another words i need the application to know where it is running from. how do i detect that?
In runtime, you can use:
Application.StartupPath
Application.ExecutablePath
that will tell you where your .exe is. Hope that helps.
If your app is a Windows Forms app you can use the Application static class, as others have noted. For other kinds of applications, use reflection:
Dim a = System.Reflection.Assembly.GetEntryAssembly()
Dim location = a.Location
I had to do this the other day, works great.
Like this:
Shared ReadOnly AppDirectory As String = _
Path.GetDirectoryName(New Uri(GetType(Program).Assembly.CodeBase).LocalPath)
You can have a look at
Application.ExecutablePath Property
or
AppDomain.BaseDirectory Property
If you put this code in your exe then it will give you the path of the exe.
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)