473,651 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checking file existance

2 New Member
how do I check if a file with a specific name exists in a folder on my computer. Im working on a macro in MSWord. Please help.

Some suggested:

Expand|Select|Wrap|Line Numbers
  1. If System.IO.File.Exists(fileToOpen) = True Then
  2. ...
  3.  
  4. Else
  5.  
  6. ...
  7.  
  8. EndIf
Jun 19 '07 #1
3 1017
borec
2 New Member
I found

Object.FileExis t(FileToOpen) but I can't get it work. Debbuger alerts error.
Jun 19 '07 #2
Killer42
8,435 Recognized Expert Expert
Some suggested:
Expand|Select|Wrap|Line Numbers
  1. If System.IO.File.Exists(fileToOpen) = True Then
  2.   ...
  3. Else
  4.   ...
  5. EndIf
Well, does it work?

As for your other post, please give us the specific details of the reported error.

Also, I don't know whether it matters (not really my area of expertise) but what version of Word is this?
Jun 19 '07 #3
Killer42
8,435 Recognized Expert Expert
Just a quick note - the Dir() function is useful for checking whether files exist.

For example...
Expand|Select|Wrap|Line Numbers
  1. If Dir(fileToOpen) = "" Then
  2.   ' File doesn't exist
  3. End If
Check the doco for parameters.
Jun 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2058
by: Cherrish Vaidiyan | last post by:
hello scholars, i am just learning PHP. i have a small requirement in urgency.i want to create a functionality of archiving in which a user can upload any file through a browser to a location. but in that functionality. I want to solve a small error in my program.The case is explained below.... If i type the path,currently my program dont check for existance of the file.ie; even if the file exist or not, the results appears as
2
1405
by: William Kossack | last post by:
I'm trying to write a program in cold fusion to check the existance of fields and data types according to requirements I was looking at the syscolumns table for some of this information but I've discovered that in my playing (creating and deleting tables) thre are multiple entries for a field that is in table that is created then deleted then created again. Is this a problem? Is there a better way to get at the information ie the...
4
1397
by: Lambuz | last post by:
Is there any way to check the existance of a window by the name ? I'm using this code: window.open("http://www.google.com",'targetWin1') If I open a window using previous code without getting immediatly return value of open method, can I get it in a second moment ? For example using the value of param sName of open method ? regards
7
1849
by: Ajit | last post by:
Is there anyway to check for existance of a file on different machine. i.e. we have a data file (text file) thats stored on some other machine as its not to be exposed in case the web server is hacked. and we want to update data from this text file into our database. I know file object but it works only locally.(i.e. work with files stored on local drive) If anyone could help me it will be great.
5
5782
by: A.M | last post by:
Hi, To check if QueryString contains a key I compaire it with null like this code: if (Request.QueryString!=null) { Label1.Text= Request.QueryString; } else
6
3667
by: Juggler | last post by:
Hi all I've written a program in VB.NET that allows the user to build quotes for installing shower enclosures. As part of the program, I've included a blank Access database. I've provided them with an interface where they can add their own clients to the database When the user upgrades to a newer version of my program, I don't want the installer to overwrite the Access database file with my blank one again. How can I tell VB.NET to check...
6
1129
by: Jm | last post by:
Hi all Im a bit of a newbie to VB.NET. Under vb6 if i used a class library DLL and it wasnt available i could use the on error resume next to get past the code that calls it and trap it afterwards and display a custom error messageor move on. I was wondering if this is possible in VB.NET, it seems to just end the program with a vb frameworkish error. Basically my code says: Imports My_Project .......
6
5252
by: PengYu.UT | last post by:
The following code open the file "example.txt" in the current directory. int main () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.close(); return 0; }
6
1354
by: Andy B | last post by:
How do you check to see if a certain folder exists? I also need to know how to check for the existance of a certain sql server database table.
0
8349
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8795
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8576
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7296
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4143
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.