Relative path names VB2010 - vb.net

I'm trying to write a little Jukebox application in VB Forms, and I need the pathnames of the sound files (\bin\Tracks\"Insert Name Here") to be relative instead of absolute, so that it may work on a different computer to mine. At the moment, I am testing with the simple Soundplayer class, and the single line of code to play a song is this:
My.Computer.Audio.Play("\bin\Tracks\" & txtCurrentlyPlaying.Text)
It works when, instead of \bin\Tracks\, I put the full pathname (C:\Documents And Settings etc.), but not when I try a relative path such as this. Can anybody help?
Thank you for your time.
Nick

Try Path.Combine(Environment.CurrentDirectory, txtCurrentlyPlaying.Text)

Related

Get a bit of code after image url in browser

I'm changing background image on hover.
The code for image url looks like this:
background-image: url('../assets/img/project1.png');
But when I look in the Chrome inspector it looks like this:
background-image: url(/img/project1.9fba20d0.png);
So when I try to change image need that code (9fba20d0) for it to work.
Why dose '9fba20d0' appear? How do I remove it or get it without hardcoding it?
I actually haven't used Vue.js, but I'm sure the random string appended to end of filename is for "cache busting" purposes.
Basically, the string changes each time you build your application so the next time you request index.html from the server it will reference the new filename (with a different random string at the end). If there was no string, the browser would look locally to find the file, which may be an outdated version, if you've made changes since last rebuild.
I'd try and understand how Vue.js is creating your production "assets", i.e. all the images and other static files and see if you have some options to change the default behavior, if need be. Might have to read the documentation pertaining to caching.
Hope that at least points you in the right direction!

Visual Basic 2010- Retrieving images using code

I am making a card game. I have 53 images for the cards and one for the back of the cards. Is there a way I can use the resource file or is there a way I can reference the folder where the program is being held with it still being relatively portable so I can move the folder and the program will still work perfectly. I thought about using a case statement and using the
My.Resources._8Hearts 'For Example
but that would take up a lot of space that I am sure can be avoided. I know this can be used to grab an image:
card1.image = System.Drawing.Image.FromFile("C:\" & variable_so_I_can_get_multiple_cards & ".png")
And using a 'for' statement to place each card in a different slot on the form
Thank you for the help
PictureBox1.Image = Image.FromFile(picPath) can retrieve an image for you,no need to add to resources in VB,and im sure u have worked with Strings so you can dynamically attach the name of each picture name (and I think also extension,.PNG seems to work best for me).
If you need it to move with the installation folder find out what your application path is using MessageBox.Show(Application.StartupPath) and then place a folder of your pictures in there and when publishing don't forget to include the folder yah? And Inno Setup (http://www.jrsoftware.org/isdl.php) is a good publishing tool...so I hear,never used it before.
If this answer works for you please dont forget to accept it as the right answer

Photoshop CS4 variable relative path not working

In Adobe Photoshop CS4, I'm trying to use variables and data sets to dynamically replace images listed on a .csv file.
When I tried to use the relative path of the images, the program throws an error "Could not apply data set because the replacement file was not found"
But according to an article in the adobe website, it should work.
Can anyone help?
Most of the time this kind of errors comes from the fact that ExtendScript is struggling with backslashes. Makes sure you escape your paths before using them. Or convert them to forward slashes:
var cleanFilePath = myFilePath.replace(/\\/g, "/");

How to play .wav in VB.NET from resources

I'm polishing a VB.NET hangman game. I added the sound of a turkey gobbling when you win the game. This is in my loop for when you win:
Dim sndPing As New SoundPlayer(My.Resources.turkey)
sndPing.Play()
My.Computer.Audio.Play("C:\Users\john\Desktop\CS120_FinalProject_Hannonv2.0\CS120_FinalProject_Hannonv1.5\FinalProject_Hangman_Hannon\FinalProject_Hangman_Hannon\Resources\turkey.wav", AudioPlayMode.Background)
I have loaded the turkey.wav file into my resources, but I cannot give it a local directory with the "\Resources\turkey.wav" or My.Resources.turkey. I'm trying to find a way to send the file when I package it.
Easy, if your resource audio file is called "Ding"
My.Computer.Audio.Play(My.Resources.Ding, AudioPlayMode.Background)
That's all folks! :)
Your code is doing the same thing twice. First you create a SoundPlayer object with an embedded resources, and then you are calling the static function "My.Computer.Audio.Play". You will want to do one or the other.
The advantage with the SoundPlayer is you can use an embedded resource (so you don't have to track the wav file down). But it does require a bit more setup.
If you want to use the static function, you can pass in a path relative to your exe location. Something like this:
My.Computer.Audio.Play(System.AppDomain.CurrentDomain.BaseDirectory & "\turkey.wav")
Note that your wav file will need to be in the same folder as your .exe for the above code to work.

the physical path for my files inside the Resources folder of XCode (for IOS)

I'm developing an application for iPad. I want to access a text file inside the Resources folder! I'm doing that in following way:
NSString* filePath = #"/Users/net4uonline/Desktop/slots2/paylines.txt";
Now, if I move my whole project from Desktop to somewhere else I know this won't work. So, is there any way to give a relative path for this file instead of the current path. Maybe like the following?
NSString* filePath = #"Resources/paylines.txt";
I know this won't work but as my file is always going to reside inside the Resources folder, so I thought this might work!
I guess you are looking for NSBundle and pathForResource:ofType: method, aren't you?