﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Programming Help Forums / Microsoft .NET / Microsoft Visual Studio  / How do i rename a file in the \AppDat\Local folder (relative path) / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Programming Help Forums</description><link>http://www.programminghelp.com/forums/</link><webMaster>forums@programminghelp.com</webMaster><lastBuildDate>Fri, 18 May 2012 09:11:02 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How do i rename a file in the \AppDat\Local folder (relative path)</title><link>http://www.programminghelp.com/forums/Topic5168-8-1.aspx</link><description>SOLVED&lt;br&gt;substitute " &amp; Environ("USERNAME") &amp; "&lt;br&gt;for USERNAME&lt;br&gt;&lt;br&gt;My.Computer.FileSystem.RenameFile("C:\Users\" &amp; Environ("USERNAME") &amp; "\AppData\Local\XPROGRAM\Settings.ini", "Settings2.ini")</description><pubDate>Wed, 10 Mar 2010 16:00:36 GMT</pubDate><dc:creator>htdw3</dc:creator></item><item><title>How do i rename a file in the \AppDat\Local folder (relative path)</title><link>http://www.programminghelp.com/forums/Topic5168-8-1.aspx</link><description>How do i rename a file in the current users \AppDat\Local folder (relative path)&lt;br&gt;Im using Visual Studio 2008&lt;br&gt;This is my first program&lt;br&gt;I renamed the program for the forum.&lt;br&gt;&lt;br&gt;If I remove the paths and execute my .exe from the \AppData\local\ folder where the settings.ini file is it works fine, but I don't want have to run the program from there.&lt;br&gt;I tried using %Username% for relative paths, but the computer can't follow the path. Do i have to write code to get the current username or how do programmers do this?&lt;br&gt;&lt;br&gt;Here's part of the program&lt;br&gt;&lt;br&gt;Code:&lt;br&gt;&lt;br&gt;    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br&gt;        If My.Computer.FileSystem.FileExists("C:\Users\%Username%\AppData\Local\X PROGRAM\Settings2.ini") Then&lt;br&gt;            MsgBox("Already loaded")&lt;br&gt;        Else&lt;br&gt;            ' Kill all X PROGRAM process&lt;br&gt;            Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("X PROGRAM")&lt;br&gt;&lt;br&gt;            For Each p As Process In pProcess&lt;br&gt;                p.Kill()&lt;br&gt;            Next&lt;br&gt;&lt;br&gt;            MsgBox("Working...")&lt;br&gt;            My.Computer.FileSystem.RenameFile("C:\Users\%Username%\AppData\Local\X PROGRAM\Settings.ini", "Settings2.ini")&lt;br&gt;            My.Computer.FileSystem.RenameFile("C:\Users\%Username%\AppData\Local\X PROGRAM\Settings1.ini", "Settings.ini")&lt;br&gt;            System.Diagnostics.Process.Start("C:\Program Files\X PROGRAM\xprogram.exe")&lt;br&gt;        End If&lt;br&gt;    End Sub&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Here is the error&lt;br&gt;&lt;br&gt;Code:&lt;br&gt;&lt;br&gt;ERROR MESSAGE BOX&lt;br&gt;                          Unhandled exception has occurred in your application. If you click ATA Continue, the application will ignore this error and attempt to &lt;br&gt;&lt;br&gt;continue. If you click Quit, the application will close immediately.&lt;br&gt;&lt;br&gt;                         Could not find file&lt;br&gt;                         C:\Users\%Username%\AppData\Local\X PROGRAM\&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;I'll try and answer any questions&lt;br&gt;Any help you guys can offer will help&lt;br&gt;Or if you could explain why this won't work&lt;br&gt;Is this the right forum or should I try a different website?&lt;br&gt;Thanks&lt;br&gt;</description><pubDate>Tue, 09 Mar 2010 10:39:14 GMT</pubDate><dc:creator>htdw3</dc:creator></item></channel></rss>
