Konu: geçersiz dosya adı karakterleri?
selam arkadaşlar,
windows da dosya adında kullanılmayan karakterler hangileri ? Dosya ismini check etmem için bu karakterler gerekiyorda Hatta hazır bir fonksiyon var ise yemede yanında yat..
teşekürler
Giriş yapmadınız. Lütfen giriş yapın yada kayıt olun.
selam arkadaşlar,
windows da dosya adında kullanılmayan karakterler hangileri ? Dosya ismini check etmem için bu karakterler gerekiyorda Hatta hazır bir fonksiyon var ise yemede yanında yat..
teşekürler
bu google ile çok kolay bulunabilecek birşey: http://msdn.microsoft.com/en-us/library … s.85).aspx
Kod Çetin Üstadın.
Muhtemelen Foxite den arşivime eklemişimdir.
Malesef linkini not almamışım :
*!* Author: Cetin BASOZ
TEXT
1) Valid filename characters are not only letters and digits. One can use other characters like -, etc. OTOH VFP has a bug in its file finding that it can't read a file even if the file has a legal name to windows OS (I mean, under windows the filename is legal, other programs like notepad, word etc can open and read w/o any problem but VFP cannot 'see' that file. A typical example is a filename that contains a comma - some versions cannot read, you have VFP9 SP2). IMHO don't be too restrictive on user, let him go write what he wants then validate the path.
2) You want to limit file name to 8 chars but that really is not needed, OS provide the short name where appropriate. Anyway you may want to combine this with Q #1 and shorten the path. While doing that OS removes the spaces and illegal characters for you and returns a short name (8.3).
So combining 2 of them and utilizing VFP's putfile() capabilities (it wouldn't accept invalid filename) you could do something like this:
ENDTEXT
Local lcFileName, llExists, lcShort
lcShort = ''
lcFileName = Putfile()
If !Empty(m.lcFileName)
llExists = File(m.lcFileName)
If !m.llExists
Strtofile('',m.lcFileName)
Endif
lcShort = GetShort(m.lcFileName)
If !m.llExists
Erase (m.lcFileName)
Endif
ENDIF
? m.lcShort
Function GetShort
Lparameters cFileName
Declare Integer GetShortPathName In Win32API ;
string @lpszLongPath, ;
string @lpszShortPath, ;
integer cchBuffer
Local lpszShortPath,lnPathlen
lpszShortPath = Replicate(Chr(0),Len(m.cFileName)+20)
lnPathlen = GetShortPathName(@m.cFileName, @m.lpszShortPath, Len(m.cFileName)+20)
If m.lnPathlen > 0
Return Substr(m.lpszShortPath, 1, m.lnPathlen)
Endif
Return ""
Endfunc
Birde bu işine yarar mı?
Foxite den yine :
* Author: Samir
c='C7hr6i)s0 0S8m9i@@th'
?CHRTRAN(c,CHRTRAN(c,'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ',''),'')
Birde bu işine yarar mı?
Foxite den yine :Visual Fox Pro* Author: Samir
c='C7hr6i)s0 0S8m9i@@th'
?CHRTRAN(c,CHRTRAN(c,'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ',''),'')
işe yaramaz "*" karakterini bile koymamışlar. ayrıca lpt1,...lpt9, com1..., con,prn vs.. birsürü özel isim var yasaklı. ben şahsen hiç kontrol etmiyorum. hatalı dosya adı verirlerse hata verir olur biter. try endtray arasında kontrol edersin. foxbase'de modi comm con diye dosya açtın mı ekranda bir boşluk oluyordu. onda da kontrol sıfırdı...