Copying a file
Copying a file
Hi,
There is a file. There are unicode characters in the name of this file. I need to copy this file to another disk. How can I do this ?
There is a file. There are unicode characters in the name of this file. I need to copy this file to another disk. How can I do this ?
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Copying a file
Code: Select all | Expand
#include "FiveWin.ch"
FUNCTION Main()
LOCAL cSourceFile := "C:\FWH1701\SAMPLES\TUTOR04.PRG"
LOCAL cTargetFile := "C:\TEMP\TURO04.TXT"
? "Copiar de", cSourceFile, "Para", cTargetFile, "..."
? "Copiado", FileCopy( cSourceFile, cTargetFile ), "bytes"
RETURN NIL
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Copying a file
Code: Select all | Expand
#Include "FiveWin.ch"
static oWnd
//----------------------------------------------------------------//
FUNCTION Main()
LOCAL oBar, cOrigen, cDestino
cOrigen := Curdrive()+":\fwh1701\samples\*.prg"
cDestino := Curdrive()+":\backup\"
DEFINE WINDOW oWnd TITLE "Copiar Archivos"
DEFINE BUTTONBAR oBar _3D OF oWnd
DEFINE BUTTON OF oBar ACTION( Copiar( cOrigen, cDestino ), oWnd:End() )
SET MESSAGE OF oWnd TO "Copiar Archivos" NOINSET CLOCK DATE KEYBOARD
ACTIVATE WINDOW oWnd CENTER
RETURN NIL
//----------------------------------------------------------------//
FUNCTION Copiar( cOrigen, cDestino )
LOCAL oFs
If .not. Lisdir( cDestino )
LMkdir( cDestino )
Endif
CURSORWAIT()
oFs := CreateObject( "Scripting.FileSystemObject" )
// oFs:CopyFile( "z:\systems\xml\*.xml" , "r:\backups\systems\xml\", .t. ) // .t. for overwrite
oFs:CopyFile( cOrigen, cDestino, .T. ) // .t. for overwrite
CURSORARROW()
? "Pronto..."
RETURN NIL
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Copying a file
Code: Select all | Expand
#Include "FiveWin.ch"
// Destino do Arquivo:
STATIC cTarget := "C: "
FUNCTION Main()
cTarget = AllTrim( cTarget )
// WinExec( "COPIAR.BAT", 0 ) // COPIAR.BAT
// DIRETO VIA FIVEWIN.
LZCopyFile( "CUSTOMER.DBF", cTarget + "\IMPREL\RONUEL.DBF" )
? [PRONTO, COPIADO!]
RETURN NIL
// FIN / END - By Joao Santos - kapiabafwh@gmail.com
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Copying a file
It can be any type of file. Problems with the header if this file was sent via whatsapp
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Copying a file
Sorry I do not understand. file was sent via whatsapp? Do you have this file for testing? Make it available for download, yes?
Put in Mega Upload for download and test please.
Regards, saludos.
Put in Mega Upload for download and test please.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Copying a file
Natter wrote:https://cloud.mail.ru/public/hiDS/DNt1MjWHS
Hello Natter, unfortunately Windows in Portuguese does not understand how to Write in Russian. I regret not being able to help. What I could do is save the file As... And rename it... But I don't think that's what you want.
https://i.imgur.com/EGPMOch.png

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Copying a file
If you can, send the original file written in Russian to my email so I can see if it saves in the source language and test it.
kapiabafwh@gmail.com
Regards, saludos.
kapiabafwh@gmail.com
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Copying a file
Dim GetShortFileName As StringDim ShortFileName As StringPrivate Declare Function GetShortPathName Lib "kernel32"
Alias "GetShortPathNameA" (ByVal longPath As String, ByVal shortPath As String, ByVal shortBufferSize As Int32) As Int32
I understand that you can get the alias of a file using the GetShortFileName function. How to implement it on xharbour ?
Alias "GetShortPathNameA" (ByVal longPath As String, ByVal shortPath As String, ByVal shortBufferSize As Int32) As Int32
I understand that you can get the alias of a file using the GetShortFileName function. How to implement it on xharbour ?
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Copying a file
look,
Regards, saludos.
Code: Select all | Expand
LOCAL cPathSource := StrCapFirst( cFilePath( GetModuleFileName( GetInstance() ) ) + cFolderBK )
LOCAL cFile := ""
cPathSource := cShortName( cPathSource )
// cFile := cGetFile( "ZipFile | *.zip", "Pasta e Nome do Arquivo Para Fazer o Backup", 1, cPathSource, .T., .T. )
cFile := cGetFile( "ZipFile | *.zip", "Pasta e Nome do Arquivo Para Backup", 1, LFN2SFN(cPathSource), .T., .T. )
.OR.
::cDataDir := LFN2SFN(Alltrim(GetVV("oApp", "cDataDir" , ::cDataDir ) ))
::cLocalDir := LFN2SFN(Alltrim(GetVV("oApp", "cLocalDir" , ::cLocalDir ) ))
::cUpdateDir:= LFN2SFN(Alltrim(GetVV("oApp", "cUpdateDir", ::cUpdateDir ) ))
.OR.
cPRGPATH := cFILEPATH(GETMODULEFILENAME(GETINSTANCE()))
cPRGPATH := cShortName(cPRGPATH) //-> Modified / Modificado al final
/*
* SPN.PRG
*
* cShortName() - FilePath Long to Short (GetShortPathNameA())
*
* Soporte a Funciones del Api de Windows
*
* Andrade A. Daniel - 2002
* Rosario, Argentina
*
* Libre Distribución
*/
/*
* cShortName()
*/
FUNCTION cShortName( cLong )
Local cShort := Space(164) + Chr(0)
Local nBuffer := 164
Local nLen
nLen := GetSPName( cLong, @cShort, nBuffer )
cShort := Left( cShort, nLen )
RETURN( cShort )
// Windows Api
DLL32 STATIC FUNCTION GetSPName( lpszLongPath AS STRING, lpszShortPath AS STRING, lBuffer AS LONG ) ;
AS LONG PASCAL FROM "GetShortPathNameA" LIB "kernel32"
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Copying a file
If the file name contains unicode characters that have no analogues in ansi (in my case, this is « and »), then the function of working with files does not work