hey guys, I really need help with this VBScript problem:

Ask the user to enter the folder name and filename. Test whether the file exists in the given folder. If the file exists, display the file size in MBs up to 2 decimal digits. If the file does not exist, display an error message as "File does not exist"

any help would be really appreciated!


Try this :

FolderName =Inputbox("Enter Folder Name","Folder Name")
FileName =Inputbox("Enter File Name","File Name")

Const bytesToMb = 1048576

Set objFSO = CreateObject("Scripting.FileSystemObject")

ShowSubFolders objFSO.GetFolder(FolderName)

Sub ShowSubFolders(Folder)

    temp = 0 
    For Each file In Folder.Files
        Set objCurFile = objFSO.GetFile(file)
        If UCase(objCurFile.Name) = UCase(FileName) Then  
            temp = temp + 1
            strFile = Folder & "\" & FileName
        End If

    Set objFile = objFSO.GetFile(strFile)

    If temp > 0 Then
        wscript.echo "File Size: " & Round(objFile.Size / bytesToMb, 2) & " Mb"
        WScript.Echo "File does not exist"
    End if

End Sub