cancel
Showing results for 
Search instead for 
Did you mean: 

FileUpload resource file modification date

Former Member
0 Kudos

Hello

I need to use an uploadfile box to select and send a file to a RFC. This is already done with the code shown above.

The question is how to get the modification or cration date of th file.

Here is my code, and I can only get the resource name and resource type.

IPrivateUploadFileVIEW.IContextElement element = wdContext.currentContextElement();

// if a file in the FileUpload field exists

if (element.getResource() != null)

{

IWDResource resource = element.getResource();

try

{

InputStream archivo = resource.read(false);

byte[] b = new byte[5000];

archivo.read(b);

//ResourceBundle.getBundle();

wdContext.currentZ_Lmmfu_Cambio_Estado_InputElement().setI_Archivo(b);

wdThis.wdGetAdministracionCMPController().executeZ_Lmmfu_Cambio_Estado_Input();

//Imprimir nombre del archivo

String name=resource.getResourceName();

wdComponentAPI.getMessageManager().reportException(name,false);

File f = new File(resource.toString());

}

catch(IOException error)

{

wdComponentAPI.getMessageManager().reportException(error.toString(),false);

}

//report success message

// wdComponentAPI.getMessageManager().reportMessage(IMessageAdministracionCMP aa ,new Object[] { resource.getResourceName()}, false);

}

else

{

// if no file in the FileUpload field exists

// report error message

wdComponentAPI.getMessageManager().reportException("Choose a file",false);

}

// clear the 'FileResource' context value attribute

element.setResource(null);

// wdThis.wdFirePlugFromCambioMasivoToActualizacion();

//@@end

}

//End of code

Thanks in advanced

Accepted Solutions (1)

Accepted Solutions (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Toxicus

It seems there is no standard way for getting FileUpload resource file modification date.

I'd suggest you the following. Include the modification date in a file name. Then at runtime parse the file name and extract the date from it:

For example, file name: "uploaded_file_05012010.txt". Extract string "05012010" and parse it into a date.

BR, Siarhei

Answers (1)

Answers (1)

Former Member
0 Kudos

The File object has a setLastModified method. Try using that.

Here's a sample code: [Change File Date|http://www.roseindia.net/java/example/java/io/ChangeFileDate.shtml]

Goodluck

Regards,

Jan

Former Member
0 Kudos

Hello.

Thank's for your replies, and happy new year.

The first answer is not posible to implement, because I don't create the files name, but it would be a nice way to do the job.

The second method I think is the one I need, but how do I do to choosing the file? I am using use FileUpload for sending the binary file, and don´t know how to access the file and path use them por file properties, because the path WebDynpro Gives starts like ..//../computersname/..... .

Is there another file browser I can use for coosing files? or how do I use FileUpload for using file properties?

Thanks for your answers.