on 12-31-2009 1:23 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.