powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Как получить дату файла
7 сообщений из 7, страница 1 из 1
Как получить дату файла
    #33304977
leokolus
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Всем привет,

Плиз хелп как получить дату файла для того чтобы его можно было переписать более новой версией.
...
Рейтинг: 0 / 0
Как получить дату файла
    #33304981
Фотография Филипп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Это, как водится ФАК, но так и быть:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
$PBExportHeader$nvo_filetimeinfo.sru
forward
global type nvo_filetimeinfo from nonvisualobject
end type
type filetime from structure within nvo_filetimeinfo
end type
type systemtime from structure within nvo_filetimeinfo
end type
type win32_file_attribute_data from structure within nvo_filetimeinfo
end type
end forward

type filetime from structure
	unsignedlong		dwLowDateTime
	unsignedlong		dwHighDateTime
end type

type systemtime from structure
	unsignedinteger		wYear
	unsignedinteger		wMonth
	unsignedinteger		wDayOfWeek
	unsignedinteger		wDay
	unsignedinteger		wHour
	unsignedinteger		wMinute
	unsignedinteger		wSecond
	unsignedinteger		wMilliseconds
end type

type win32_file_attribute_data from structure
	unsignedlong		dwFileAttributes
	filetime		ftCreationTime
	filetime		ftLastAccessTime
	filetime		ftLastWriteTime
	unsignedlong		nFileSizeHigh
	unsignedlong		nFileSizeLow
end type

global type nvo_filetimeinfo from nonvisualobject autoinstantiate
end type

type prototypes
FUNCTION boolean GetFileAttributesExA(ref string name,int k,ref WIN32_FILE_ATTRIBUTE_DATA attr) LIBRARY "Kernel32.dll"
FUNCTION boolean FileTimeToSystemTime(ref FILETIME dd,ref SYSTEMTIME s1) LIBRARY "Kernel32.dll"
FUNCTION boolean FileTimeToLocalFileTime(ref FILETIME d1,ref FILETIME d2) LIBRARY "Kernel32.dll"
end prototypes

forward prototypes
public function integer getfilemoddate (readonly string szwhatfilename, ref string as_moddate)
end prototypes

public function integer getfilemoddate (readonly string szwhatfilename, ref string as_moddate);/*------------------------------------------------------------------------------

 Function:			public nvo_filetimeinfo.Getfilemoddate

 Returns:         Integer

 Parameters:      readonly String szwhatfilename
                  reference String as_moddate

 Copyright ©2003 DTI - Philip Salgannik

 Date Created: 3/26/2003

 Description:	
 
--------------------------------------------------------------------------------
 Modifications:
 Date            Author              Comments
------------------------------------------------------------------------------*/


WIN32_FILE_ATTRIBUTE_DATA fa
FILETIME fdt, fdt_local
SYSTEMTIME s_dt
boolean rtn
string sztmp

sztmp = szWhatFileName
IF NOT GetFileAttributesExA(sztmp, 0 ,fa) THEN 
	as_moddate = "Error - most likely Path is not Valid"
	RETURN - 1 
END IF

fdt.dwLowDateTime = fa.ftLastWriteTime.dwlowdatetime
fdt.dwHighDateTime = fa.ftLastWriteTime.dwhighdatetime

IF NOT FileTimeToLocalFileTime(fdt, fdt_local) THEN 
	as_moddate = "Could not convert to Local Time"
	RETURN - 1 
END IF 
IF NOT FileTimeToSystemTime(fdt_local,s_dt) THEN
	as_moddate = "Could not convert to System Time"
	RETURN - 1 
END IF
	

as_moddate = string(datetime(date(s_dt.wyear,s_dt.wmonth,s_dt.wday), &
								time(s_dt.whour,s_dt.wminute,s_dt.wsecond)),'yyyy-mm-dd hh:mm:ss')
								
RETURN  1 


end function

on nvo_filetimeinfo.create
call super::create
TriggerEvent( this, "constructor" )
end on

on nvo_filetimeinfo.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on
...
Рейтинг: 0 / 0
Как получить дату файла
    #33304994
leokolus
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Филлип,

плиз спасибо, только не пойму как использовать эту фунцию, вставить то её я вставил а как вызывать, плиз примерчик как получить дату например файла на диске с:\myFile.doc
...
Рейтинг: 0 / 0
Как получить дату файла
    #33305004
Фотография Филипп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Нее дружок, еду свою сам жуй...
...
Рейтинг: 0 / 0
Как получить дату файла
    #33305030
leokolus
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Ищт что нащёл в интернете но не пойму как его можно ипользовать, кто прокоментирует. плиз - как это вставить в свою программу?

Retrieve a file timestamp

[structure]
type os_filedatetime from structure
unsignedlong ul_lowdatetime
unsignedlong ul_highdatetime
end type

type os_finddata from structure
unsignedlong ul_fileattributes
os_filedatetime str_creationtime
os_filedatetime str_lastaccesstime
os_filedatetime str_lastwritetime
unsignedlong ul_filesizehigh
unsignedlong ul_filesizelow
unsignedlong ul_reserved0
unsignedlong ul_reserved1
character ch_filename[260]
character ch_alternatefilename[14]
end type

type os_systemdatetime from structure
uint wYear
uint wMonth
uint wDayOfWeek
uint wDay
uint wHour
uint wMinute
uint wSecond
uint wMillisecond
end type

[external function declaration]
FUNCTION long FindFirstFileA &
( string filename, ref os_finddata findfiledata) &
LIBRARY "KERNEL32.DLL"
FUNCTION boolean FindClose (long handle) LIBRARY "KERNEL32.DLL"
FUNCTION boolean FileTimeToLocalFileTime &
( ref os_filedatetime lpFileTime, ref os_filedatetime lpLocalFileTime) &
LIBRARY "KERNEL32.DLL"
FUNCTION boolean FileTimeToSystemTime &
(ref os_filedatetime lpFileTime, ref os_systemdatetime lpSystemTime) &
LIBRARY "KERNEL32.DLL"

[powerscript]
os_FindData lstr_FindData
os_FindData lstr_FindDataTemp
os_SystemDatetime lstr_SystemDateTime
long handle
String ls_timestamp

handle=FindFirstFileA &
("C:\Program Files\Sybase\PowerBuilder 9.0\pb90.exe", lstr_FindData)

IF handle=-1 THEN
// something wrong!
ELSE
FileClose(handle)
FileTimeToLocalFileTime &
(lstr_FindData.str_lastwritetime, lstr_FindDataTemp.str_lastwritetime)
IF FileTimeToSystemTime &
(lstr_FindDataTemp.str_lastwritetime, lstr_SystemDateTime) THEN
ls_timestamp = string &
(datetime(date(lstr_SystemDateTime.wYear, &
lstr_SystemDateTime.wMonth, lstr_SystemDateTime.wDay), &
time(lstr_SystemDateTime.wHour, &
lstr_SystemDateTime.wMinute, lstr_SystemDateTime.wSecond)), &
"mm/dd/yyyy hh:mm:ss")
MessageBox("PB9", ls_timestamp)
END IF
END IF
...
Рейтинг: 0 / 0
Как получить дату файла
    #33305336
Фотография AIZ
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
В PFC есть n_cst_filesrvwin32 of_dirlist() и n_cst_dirattrib
...
Рейтинг: 0 / 0
Как получить дату файла
    #33305546
Фотография ChV
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
У Филиппа, как всегда, классные примеры, но если это сложно, можно и попроще :
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
public function boolean uf_get_file_property (string s_file, ref str_file_property s_pr);
str_file_property s_p
OLEObject o_file, o_pusto

	if o_pusto 		= fso then this.uf_fso_create()
	o_file 			= fso.GetFile(s_file)
	s_p.path		= o_file.path
	s_p.name  		= o_file.name
	s_p.s_type  		= o_file.type
	s_p.date_created  	= o_file.datecreated
	s_p.date_last_accessed	= o_file.datelastaccessed
	s_p.date_last_modified  = o_file.datelastmodified
	s_p.size 		= o_file.size
	s_pr			= s_p
Return True 
end function

public function boolean uf_fso_create ();Integer rc
String s_Soob
fso= CREATE OLEObject    
rc = fso.ConnectToNewObject( "Scripting.FileSystemObject" )  
if rc <>  0  then
		s_Soob = Soob_common + '"uf_fso_create"~n'
		CHOOSE CASE rc
			CASE - 1 
				s_Soob = s_Soob + 'Invalid Call: the argument is the Object property of a control'
			CASE - 1 
				s_Soob = s_Soob + 'Class name not found'
			CASE - 2 
				s_Soob = s_Soob + 'Invalid Call: the argument is the Object property of a control'
			CASE - 3 
				s_Soob = s_Soob + 'Object could not be created'
			CASE - 4 
				s_Soob = s_Soob + 'Could not connect to object'
			CASE - 9 
				s_Soob = s_Soob + 'Other error'
			CASE - 15 
				s_Soob = s_Soob + 'MTS is not loaded on this computer'
			CASE - 16 
				s_Soob = s_Soob + 'Invalid Call: this function not applicable'
			CASE ELSE
				if isNull(rc) then
						s_Soob = s_Soob + 'any argument value is NULL, ConnectToNewObject returns NULL.'
				else
						s_Soob = s_Soob + 'rc = ' + String(rc)
				end if
		END CHOOSE
					uf_log( s_Soob )
		if Not Appl.b_no_dial then
					MessageBox('Error', s_Soob )
		end if
		Return False
end if
Return True

end function

global type str_file_property from structure
	string		path
	string		name
	string		s_type
	datetime		date_created
	datetime		date_last_accessed
	datetime		date_last_modified
	decimal {  0  }		size
end type

...
Рейтинг: 0 / 0
7 сообщений из 7, страница 1 из 1
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Как получить дату файла
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]