I'm trying to write a small script that will copy a folder (named .minecraft) to a new folder (doesn't exist, but I want to create a new folder called .minecraft_backups).
The current code I have is:
My.Computer.FileSystem.CopyDirectory("%appdata%/.minecraft", "%appdata%/.minecraft_backups", True)
I get an error saying:
Could not find directory '%appdata%/.minecraft'.
I'm guessing it's because of the %appdata% shortcut. Is there any workaround to do this? The reason for this is because obviously if I don't enter %appdata% and enter the full route to the directory I need to enter the users username for the computer.
Could anyone write a tiny piece of code to do this?
Try the following to get an string representation of your environment variables.
http://msdn.microsoft.com/en-us/library/system.environment.expandenvironmentvariables.aspx
Related
A program I am developing is using a Windows Tasks Scheduler script inside a project folder (CRM_Window10). I am trying to have it so that when my program runs it moves the folder with the script to "C:\Windows\System32\Tasks" where it then creates the folder win10 and puts the contents of CRM_Window10 into. To accomplish this I am using the IO.Directory.Move method. I am not getting an error and I know it is moving the folder because it deletes CRM_Window10, but it does not appear inside of the "C:\Windows\System32\Tasks" folder.
IO.Directory.Move(IO.Directory.GetCurrentDirectory & "\idle_setup\CRM_Window10", "C:\Windows\System32\Tasks\win10")
The expected result that it moves the contents of CRM_Window10 to a newly created folder win10 in the "C:\Windows\System32\Tasks" folder with the script inside. The actual results are that it tries to move CRM_Window10 but can't make it inside of the "C:\Windows\System32\Tasks" folder.
Thanks!
I was deleting an Access Object (a report) and Access crashed during the delete.
The object no longer exists in Access, but its module still shows up in VBA like a ghost.
If I click on it, I get a FILE NOT FOUND error.
If I try to compact & repair or compile the database, I get a FILE NOT FOUND error.
How can I solve this problem?
A potential option is to create a new database file, and import all of the content from the old database file. that will clear out the funky ghost stuff.
you write you tried compile already and it did not work.
Did you try decompile first though?
First of all make a backup copy (but am sure you already did that :) )
With Access and your access file closed type from the command prompt:
C:\yourOfficeInstallPath\MSACCESS.EXE /decompile
Access will start. Click File > Open and select the database you want to decompile
Open any module and click Debug > Compile
Then save your file and close.
Open again your file and compact it.
Let me know if it solved it.
OK so currently this is the code I have below of a picture box
PxBx.Image = Image.FromFile("C:\Users\Ashleysaurus\Documents\Visual Studio 2015\Projects\ThisProject\ThisProject\Images\filename.JPG")
What is the correct syntax for using images files stored in the application files after i publish a project? Namely b/c this path will not always be the same based off when/where users would store the app files?
I did a bit of searching but havent figured out how to ask the correct question to get the answer from forums/google.
Thanks in advance
I suggest you to add to your Settings.settings a new entry for the path to the folder where you store the images. This setting will be read at runtime and used to find your images. The advantage of this approach is that you can manually (or through your setup code) change the config file (where the setting is stored) to whatever your customer requires. Instead, hard coding a path (relative or not) inside the code is just a problem waiting to happen.
To add an entry in your setting.settings file right click your project and select properties, then the settings tab. Here, add a Name like "ImagePath", of Type = String and Scope = "Application", then set your current path as value and save.
Now, if you open the app.config (or web.config) file you will see the new entry and its value. To use it at runtime
string imagePath = Properties.Settings.Default.ImagePath;
You can utilize the Application.StartupPath property and use Path.Combine() to construct a proper path:
PxBx.Image = Image.FromFile(Path.Combine(Application.StartupPath, "Images", "filename.JPG"))
You have to add the image to the project.
You have 2 ways:
Create a folder in your solution explorer called Images or whatever you want. Right click on it and click 'Add Existing Item'. Choose the image you want.
Then type in your code:
PxBx.Image = Image.FromFile("Images\FileName.jpg")
Click on your project name in the solution explorer. It will take you to a new "screen" (I don't know how to call it), from the right click on 'Resources', from there you can add your image.
Then you reference it in your code using:
PxBx.Image = My.Resources.Filename
I'm trying to get the path to the final output directory where the assemblies are copied to.
For example: C:\Builds\My_Task\My_Build.DATE.BUILDNUMBER
(After a finished build, everything is located here)
Each of the macros $(OutDir) and $(TargetDir) points to a Directory called:
C:\Builds\1\WorkspaceName\My_Task\Binaries
Does such a macro that points to the first described location exists? Or how can I get that path into a macro so that I can use it in my msbuild-scripts?
So I finally got around my Problem, but I didn't found a way to get the real drop location directly into an msbuild-Skript.
I found the following question, and editing the Build-Process template works fine:
How can I get TFS 2010 to build each project to a separate directory?
Please try using the $(DropLocation) macro to point to C:\Builds\My_Task\My_Build.DATE.BUILDNUMBER and see how that works out for you.
I have to copy files, make a new folder and then paste those files into the new folder so often.
I wonder if we can make a batch file or vbscript file to perform this task? Just select the files and choose "Group to New Folder" from the context menu. That'll be awesome!
I've found a solution in .NET 4.0
http://blogs.msdn.com/b/codefx/archive/2010/09/14/writing-windows-shell-extension-with-net-framework-4-c-vb-net-part-1.aspx
What you want to do is write an HTA application. You could have a selection listbox that could be auto-populated with the current folders files when you first launch the hta. Then just have a simple button than will prompt you for a folder path/name to create when selected and a simple sub to just move the selected files over, maybe through results to the screen or something. Obviously with error trapping and all that's a little bit much code to just paste in here, but it should be pretty easy to do.
If you're looking for help getting started with the hta interface, I recommend you check out the "HTA Helpomatic" which you can use to get the basic GUI, as well as selection box code. Obviously you can write the script subs to do the real work.