I'm creating a program that counts files, but the special environments folders won't pick up. This program searches C:/Windows/Temp for files and counts them. But I keep getting the error
It shouldn't be pointing to "C:\Users\Jimmy\Desktop\Work\etc.." It should be pointing to "C:\Windows\Temp\". I've also tested this script with the "Environment.SpecialFolder.UserProfile" Environment and when I search folders in my user profile it points back to "C:\Users\Jimmy\Desktop\Work\etc.." I'm soo confusedQuote:
An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
Additional information: Could not find a part of the path 'C:\Users\Jimmy\Desktop\work\WindowsApplication5\WindowsApplication5\bin\Debug\36Temp'.
Can someone please help? It should work I'm not understanding.
Code:Option Explicit On
Option Strict On
Option Infer Off
Imports System.IO
Imports System.Collections.Generic
Imports System.Linq
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a1 As Integer = IO.Directory.GetFiles(Environment.SpecialFolder.Windows & "Temp/", "*.*", SearchOption.AllDirectories).Length
MessageBox.Show(String.Format("Total Files: {0}", a1), "Total Files", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class

