Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • Last Modified:

Open File Names with Single Quotes in the File Name!

I have a that gets sent to a Main Frame system which requires the file name to have single quotes on each end of the file.

Example:
'PSDH.XM.M2.P900.CGS.DXMEXT00'

This is a text file you can view in Notepad, and I'm trying to write a program that opens the file and verifies the date in the header record before it gets sent to the Main Frame to ensure the operator is sending the correct file.

I'm unable to open the file because the command doesn't work:

sFilePath = "c:\'PSDH.XM.M2.P900.CGS.DXMEXT00'"

Open sFilePath For Output As lFileNum

The sFilePath ends up looking like this in debug: "c:\'PSDH.XM.M2.P900.CGS.DXMEXT00"'

Any ideas on how I can read this file in to verify the header record???

Thanks,
smithmrk
0
smithmrk
Asked:
smithmrk
  • 2
1 Solution
 
Z_BeeblebroxCommented:
What exactly is the problem? I tried something similar here and it worked fine. Why are you opening the file for output if you want to read the file header?

Zaphod.
0
 
smithmrkAuthor Commented:
Ok Your Right I had Output instead of Input!

However now it jumps right to Close File??
Error 62 Past End of File?

I only want the first line of the file anyway.
Let me know what happens on your end.

Thanks!

sFilePath = "c:\'PSDH.XM.M2.P900.CGS.DXMEXT00'"

On Error GoTo ErrorHandler

lFileNum = FreeFile

Open sFilePath For Input As lFileNum

Do Until EOF(lFileNum) = True
    Line Input #lFileNum, sFileLine
    sFileDate = sFileLine
    Exit Do
Loop

Close #lFileNum

0
 
smithmrkAuthor Commented:
OK I'm a Dumb Ass!

When I had the Output Statement instead of the Input Statement I over wrote my file with nothing in it.

Therefore once I changed the Output to Input using the same file there was nothing to read in.

Dumb Ass!

Long Day, but thanks for your help and pointing out my Output vs Input statement.  I was so sure it had to do with the signal quote thing.

You guys rock!
Thanks again,
smithmrk
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now