Liberty BASIC Community Forum
« For Windows, "data.txt" and "data.txt." are same »

Welcome Guest. Please Login or Register.
Mar 17th, 2018, 05:45am

Rules|Home|Help|Search|Recent Posts|Notification

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: For Windows, "data.txt" and "data.txt." are same  (Read 179 times)
Board Moderator

member is offline


Anatoly (real name)


Gender: Male
Posts: 1748
xx For Windows, "data.txt" and "data.txt." are same
« Thread started on: Nov 23rd, 2017, 02:19am »

While trying to check code for file found/file not found,
I encountered that FILES for
returns data for

First I thought that to be a bug in FILES,
but I saw that C# behaves same way.

After some googling it seems that file name ending with a dot is invalid in Windows - so Windows silently strips final dots.
Here's the code proving that (tested on WinXP SP3. Google says problem manifests in Win7, and I think in lates Windows too.

I really find this amusing.

'code shows that for Windows,
'   "data.txt"
'   "data.txt..."
'are the same thing
'(tsh73 Nov 2017, tested on XP SP3)

'fileName$="data.txt..."    'creates "data.txt", no extra dots

'create data file
open fileName$ for output as #1
    print #1, "data goes here"
close #1

fileName$ = fileName$+"....................."   'opens "data.txt", extra dots are ignored
print "Time stamp for a file ";fileName$
print getFileStamp$(fileName$)

function getFileStamp$(fileName$)
    dim info$(1,1)
    files  DefaultDir$, fileName$, info$()
    if info$(0, 0) = "0" then
        getFileStamp$ = "File not found"
        getFileStamp$ = info$(1, 2)
    end if
end function
User IP Logged

damned Dog in the Manger
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls