JME Socket File Transfer - Problem with writing file

Hi everybody, i'm trying to code a P2P app for a school project and i have a problem when trying to write to a file.
This method recieves a file form a Socket Server computer that tries to send me a file to the mobile client.
The method recieves the IP adress (String add) and the port of the server.
Also, i would like to know about the buffer(byte) size.
This codes runs well in emulation, but it doesn`t write to a file.
And the main problem is:
"When i run this in the mobile, the file is created in the cellphone memory with a size of 0kb."
The server code was tested with a computer client and recieved the file succesfully.
The server recieves de socket connection form the cellphone without problem.
public void recibirArch(String add, int port) throws Exception {
try
recibArch.setText("Espere por favor...");
long start = System.currentTimeMillis();
int bytesRead;
int pasos = 12;
int current =0;
SocketConnection sock = (SocketConnection)Connector.open("socket://"+add+":"+port);
byte [] mybytearray = new byte [1024];
InputStream is = sock.openInputStream();
FileConnection fc = (FileConnection) Connector.open("file:///"+saveRoot+"5letras.txt",Connector.READ_WRITE );
if( !fc.exists() ){
fc.create();
} else
fc.truncate(0);
DataOutputStream fos = new DataOutputStream(sock.openOutputStream());
bytesRead = is.read(mybytearray,0,mybytearray.length);
current = bytesRead;
while ((current = is.read(mybytearray)) != -1)
fos.write(mybytearray, 0, current);
fos.flush();
current+=bytesRead;
long end = System.currentTimeMillis();
fos.close();
sock.close()
catch(Exception err)
String error = "ERROR: " + err.toString() + "\nDescripción: "+ err.getMessage();
System.out.println(error);
txtLog.setString(error);
Edited by: xtylo on Sep 30, 2008 10:56 AM

Thank you Tunde for looking at my issues!
The file size is not an issue here. We tested with empty files or files with smaller than 1KB sizes. They all showed problem. The frequency of file transfer shouldn't be a problem either. Through some user interaction on front panel, a couple of files will be transferred. That's basically how often the file transfer occurs.
Interestingly enough, I replaced the copy.vi with a subvi I created using DOS command with System Exec.vi and the issue of copying files went away. My co-worker tested on both XP machine and Windows 7 machine. The DOS command worked fine thru Lavview's System Exec.vi. I think I can take that as a work-around if we can't figured out why copy.vi wouldn't work. Still, it would be nice to know why it doesn't work.
Now I'm still facing some issues with the usage of Check If File or Folder exist.vi. Sometimes it can detect the existing files and sometimes it doesn't.
Thanks very much! 

Similar Messages

  • Bluetooth File Transfer Problem with Video Clips -...

    Hello!
    I am posting this problem even though a similar one is claimed to be solved ...
    I have a similar Problem with BT video clip file transfer in my E5-00 as someone had earlier with music files (SW up to date). Except that in this case the files are unique video clips received from one of the latest Samsung Android phones via Bluetooth (don't ask me which format).
    Tried the obvious first, using Windows File Manager over USB. Even Windows Search could not locate the files, not even using wildcards.
    Also tried using Ovi Suite Syncronisation, but the files did not appear in either Photos/Videos or Messages (even though the files are in the SMS Inbox - does not make sense why). 
    The problem in applying the solution approach presented here for Music seems to be that the files cannot be played at all in my E5-00's. Therefore I don't get as far as to the menu where the E5 would ask whether or not the files should be saved or not.
    So far I have not been able to connect to an old bluetooth laptop (Windows XP) so that the Bluetooth Exchange would connect let alone seen whether the BTexchange works in this case or not.
    Is there any other chance of getting to the files through the directory structure? If so, please give me the (Windows) directory path? Any other advice than switching to Android?

    Unfortunately I have reached an impasse.  If I touch a video clip (in organizer) the system crashes.  I mean locked up cold. I'm not sure what has caused this but I do know that I will not be able to communicate correctly or sufficiently with you in order for you to help me out.
    I've found PS and Premier to be very difficult to work with.  Very, very frustrating.  Photography, both still and video, is not as enjoyable as it once was.
    Again, I very much appreciate your initial help and if I get to a point where I've improved my situation ... I'll reach out again.  Thanks

  • Problems with writing files after migration

    I migrated my old Pismo HD to a new MacBook Pro (a frustrating process which I eventully had to accomplish using a clone of the Pismo disk and a firewire drive) and have a couple of issues.
    The most troublesome at the moment is a problem with Safari. It will not let me download files when I am operating as the migrated user, although it will allow downloads if I log in as the user I established during initial setup.
    I am also having trouble using Spotlight or the Find utility. Most of the time when I use these, the computer either goes into a kernel panic or grinds away for minutes and never finds anything before I give up in frustration. However, the find function on the top right of finder windows works well.
    Any suggestions welcome, thanks!
    Various   Mac OS X (10.4.8)  

    Thanks for the suggestions. I had already tried the "Get Info" route with Safari.
    The "sudo mdutil -E /" seems to have worked for Spotlight. I did get an error message saying that my volume was not indexed; however, it seems to work now. (I'll get around to indexing the disk eventually.)
    I repaired the permissions on my startup disk from the install CD, but the Safari problem is still there (same problem with Firefox).
    Any other ideas most appreciated.

  • File upload: problem with writing uploaded file to server-harddisk

    Hello,
    according to the example in the File upload tutorial, I tried to save an uploaded file to disk, but it didn't work (and also no messages / exceptions were thrown).
    The Javadoc for the function uploadedFile.write(filename) says that if the file should be written in an other directory than the servers' tmp-directory, the server.policy has to be adjusted.
    The following line is already included in my server.policy:
    permission java.io.FilePermission "<<ALL FILES>>", "read,write";
    So I have two questions:
    1) Where can I find the servers' tmp-directory?
    2) How should the sever.policy permission code look like?

    The File Upload tutorial at http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/file_upload.html has you save the uploaded file to disk. It also gives this information:
    The server holds the uploaded file in memory unless it exceeds 4096 bytes, in which case the server holds the file contents in a temporary file. You can change this threshold by modifying the sizeThreshold parameter for the UploadFilter filter entry in the web application's web.xml file. For more information on modifying the web.xml file, see the last section in this tutorial, Doing More: Modifying the Maximum File Upload Size.
    In cases where you want to retain the uploaded file, you have three choices:
    * Write the file to a location of your choosing, as shown in this tutorial.
    * Create an UploadedFile property in a managed bean and set it to the component's value before you exit the page (as in the button's action method).
    * Save the file to a database.
    By default, the File Upload component can handle files up to one megabyte in size. You can change the maximum file size by modifying the maxSize parameter for the UploadFilter filter entry in the application's web.xml file, as described in the last section in this tutorial, Doing More: Modifying the Maximum File Upload Size.

  • Log and transfer problem with prores files

    Working on RED project. Started several months ago. Shooting and logging as we go. Project setup on FCP, RED media converted to prores422 proxy with RED software(rocketcineX) and saved on Internal 2 TB RAID. NO problems for past 4 months. Moving prores422 proxy files into FCP via Log and Transfer. (I thought this was necessary, is it?) Anyway its working just fine. Loaded a thousand or so clips to date. Last transfer was August when brought in some P2 media. Now when I go and try to bring in the prores422 proxy clips as before suddenly I get error message of "unsupported media or invalid directory structure. This even applies to all the older files that I had already transferred by log and transfer. They worked before but now they don't. Any suggestions as to why the change? The project will be conformed back to original RED r3D files after edit. Any help greatly appreciated.
    Thanks,
    Jeff

    First, get Preference Manager from Digital Rebellion (free) and trash FCP preference files. Run Disk Utility to repair all drives (Repair Permissions on OS drive). This should be done once a week, anyway. Disk Warrior would be your last resort (and should be run once a month on your drives, anyway). If Disk Warrior won't fix the problem, you have a dead hard drive. Replace it, restore from the backup you've been making of your data on a regular basis. I mean, you do have a backup that you do almost daily for such a large and important project, right?

  • File transfer problem with adobe reader in iTunes

    I use adobe Reader on my iPad Air for work and at the end of each day transfer the files to my Mac at home through iTunes. Lately i am getting an error message "file could not be copied because an error occurred. A duplicate file name was specified." I have updated everything i can think of..any suggestions?

    Hi,
    Your question is not about FormsCentral. I suggest you to check whether Adobe Reader is enabled on your web browser's add-in list. For example, on Chrome you may type in "chrome://plugins/" to open the Plug-ins list, and check the status of Adobe Reader. If it's not the latest version, you may update it as well.
    You may go to Adobe Reader's forums and start a discussion if you like: http://forums.adobe.com/community/adobe_reader_forums
    Kind regards,
    Shiyao Bao

  • File transfer Problem with open dataset

    I am transfering file in ECC6.0 unicode system to nonsap.In al11 transaction the file has the '#' symbol in the text field.But while downloading to local system to upload other legasy it is taking as Tab.so the file is corrupting.I have tried with field symbols also it is not working.Can any one help on this..
    Thanks in advance,
    Bhagya

    Hi Bhagya,
    in Unicode systems, AL11 expects files to contain data encoded in UTF-8 - hence if the file contains UTF-8, the transaction will work. In case of Non-Unicode, special characters will be displayed as '#'.
    One workaround could be  to convert the data to UTF-8 e.g. with tools described in 747615.
    Best regards,
    Nils Bürckel
    Solution Management
    Globalization Services
    SAP AG

  • Log and Transfer problem with MXF files

    Hi, folks.  I've spent an hour searching the threads, but I haven't found an answer to my problem (or anyone who's had the same problem).  Please help if you can!
    We're using the Canon XF300 and we tested some footage a couple weeks ago.  We ingested it into Final Cut Pro (7.0.3) using Log and Transfer (after installing the Canon plugin) and it all came through perfectly.  Worked without a problem.
    Now, we have a week's worth of field footage, captured exactly the same way, transferred to the same hard drive, exactly the same as the test footage...
    See what I'm getting at?  EVERYTHING has been done the same.  Identical.
    And yet the new footage is not being recognized in the Log and Transfer window.
    Instead, this is what's happening:
    What gives?  Everything we're doing is identical to the testing we did a couple weeks ago.  Like I said, I've searched the forums, read a couple dozen threads, followed the Creative Cow link mentioned in several of them.  I must be missing something.  Please fill in the gap for me.  Thank you!
    Like I said before, we've downloaded the Canon plugin, imported test footage at ProRes 422, watched it, edited it, enjoyed it.  But now our new footage is unrecognizable by FCP.  And the directory structure is identical to that of the test footage.
    Sigh...

    UPDATE --
    The field producers transferred the footage incorrectly.  They left off the master directory and went in 1 directory too far.
    Yes, David, the frame rate was all the same (30p).
    Russ... I imagine you were going to say something along the lines of "MAKE SURE YOU INCLUDE THE ENTIRE DIRECTORY."  Leave nothing behind.
    Now... the question is... can I create a new CONTENTS folder and simply drag the CLIPS folder into it?

  • Problem with Image file

    Hi,
    Iam facing with one problem.I have one swing interface through which I can upload files(back end servlet programme).Now I can upload all types of file but problem with image file it uploading perfectly that means size of the uploaded file is ok but its format damaged.It can not be open.My backend servlet programme is ok coz i tested it with html form it is working perfectly.Problem with swing interface.Plz guide me where I done a mistake.Below r my codes:-
    ImageIcon Upload=new ImageIcon("images/Upload.gif");
         Button=new JButton(Upload);
         Button.setToolTipText("Upload");
    Button.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
              int returnVal = fc.showOpenDialog(ActionDemo4.this);
              if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
    String aa=file.getAbsolutePath();
              textArea3.append(aa);
                   textArea2.append("Local URL:");
    long l=file.length();
              try
              byte buff[]=new byte[(int)file.length()];
              InputStream fileIn=new FileInputStream(aa);
              int i=fileIn.read(buff);
              String conffile=new String(buff);
              String str1=textArea10.getText();
    url = new URL ("http://127.0.0.1:7001/servletUpload?x="+str1);
         urlConn = url.openConnection();
         urlConn.setDoInput (true);
         urlConn.setDoOutput (true);
         urlConn.setUseCaches (false);
         urlConn.setRequestProperty("Content-Type","multipart/form-data;boundry=-----------------------------7d11e410e500f2");
         printout = new DataOutputStream (urlConn.getOutputStream ());
    String content ="-----------------------------7d11e410e500f2\r\n"+"Content-Disposition: form-data;"+"name=\"upload\"; filename=\""+aa+"\"\r\n"+"Content-Type: application/octet-strem\r\n\r\n\r\n"+conffile+"-----------------------------7d11e410e500f2--\r\n";
    printout.writeBytes(content);
    printout.flush ();
    printout.close ();
    Best Regards
    Bikash

    The errors are here:
              byte buff[]=new byte[(int)file.length()];
              InputStream fileIn=new FileInputStream(aa);
              int i=fileIn.read(buff);
              String conffile=new String(buff); (conffile is a String object containing the image)
    and here:
    String content ="-----------------------------7d11e410e500f2\r\n"+"Con
    ent-Disposition: form-data;"+"name=\"upload\";
    filename=\""+aa+"\"\r\n"+"Content-Type:
    application/octet-strem\r\n\r\n\r\n"+conffile+"--------
    --------------------7d11e410e500f2--\r\n";
    printout.writeBytes(content);conffie is sent to the server but
    it's non possible to treat binary data as String!
    Image files must be sent as byte[] NOT as String ......

  • File transfer problem

    I have a 2009 intel iMAC running 10.6.8.  Several months ago it developed a file transfer problem.  When transferring files to an external server via ethernet cable, most of the time it will only let me transfer one file at a time whether is a small word document or a large video file that is several gigabytes.   Even with transferring just one file, the elapsed time bar will not indicate the file has completely transferred.  It stays open and appears as if it is still trying to transfer even though the file size transferred is equal to the size of the file.  Plus the only way I can close the the transfer bar is to relaunch finder.  Then when I go to the folder it was transferring it to, the entire file will be there.
    Suggestions?

    Have you tried restarting the external drive and the computer?

  • Error: There is a problem with the file and it cannot be copied

    I've been trying to copy (and essentially move) the contents of an NTFS-formatted external HDD to my iMac's internal HDD so I can then format the external HDD to Mac OS Extended. However, when I simply try to drag and drop, I get an error during the transfer that states:
    There is a problem with the file and it cannot be copied.
    I tried a basic cp command in Terminal to copy all contents of the external HDD to a folder on my iMac's desktop, and found that while there were no errors, there were many individual files missing full chunks of data (ie. original file would be 4GB on my external HDD, but only 350MB on my desktop).
    Any ideas on how I can successfully copy a large amount of data (approx. 170GB) from my external HDD to my internal HDD while avoiding this error, so I can ultimately format my external HDD to Mac OS Extended? ANY help is greatly appreciated.

    That's not a good error to see. It indicates something is very wrong. Pulled out of an old programming header file:
    ioErr = -36, /*I/O error (bummers)*/
    If Apple labelled it "bummers," they had a good reason! Unfortunately, that doesn't bode well for you.
    Try running Disk Utility again. Keep repairing over and over until one of two things happens: 1) Disk Utility says no repair was needed, or 2) Disk Utility reports the same error in two sequential repair sessions and is unable to repair it both times.
    If you hit the second case, or if you hit the first but still can't copy files, then you've got two basic options:
    = Buy a third-party disk utility or two and try them. Try TechTool as a first choice.
    = Recover what files you can and write the rest off as gone.
    = Send your drive to a data recovery service and hope they can extract more than you can.
    Of course, none of this is necessary if you have a backup of the contents of that hard drive. (If you don't, this is your learning experience. Once bitten, twice shy, so they say.) Also, regardless of the outcome, once you've got your data or have decided it's gone, you're going to want to wipe that drive completely clean. Reformat the drive with Disk Utility, then when it's done, select the drive in Disk Utility and hit command-i. (Don't select the new volume you just created on that drive, select the drive itself. Mine looks like "232.9 GB Hitachi ..." with the volume name indented underneath.) Look for an item that says S.M.A.R.T. Status, and if it doesn't say Verified, you might as well throw out the drive. Don't trust any more data to it.
    If all appears safe, you can start moving data back onto it. But, as always, make sure you have a backup of everything!

  • New to MacBook - slow LAN file transfer problem

    My new MacBook is painfully slow when wifi-ing to my house LAN.
    I turned in my old G4 iBook for a MacBook (2GHz C2D, 2GB, 10.4.9, all updates). I have a LAN that consists of a wired 1G Ethernet backbone (a Mini and a Powermac G5 are wired in) and a Snow AEB that provides 802.11g wifi access to the LAN. The wired LAN connects to a D-Link GB Ethernet switch so the wired systems can exchange files fast. The switch connects to a D-Link EBR2310 router that connects to a cable modem to ComCast. The router has the latest firmware (1.05, it's an 'A' version router).
    The Mini, G5, and MB are static IPs on the LAN. The D-Link router passes out DHCP addresses >100, with addresses <101 reserved for static LAN IPs. I use static IPs for network reliability when recovering from power outages and other unforeseen glitches. The LAN has worked very well in this configuration, with fast file transfers among machines and good stability.
    With my old 802.11g G4 iBook, I was able to watch DVDs that are stored on an external FW drive connected to the Mini. No stalls, no pauses, no dropouts - MenuMeters showed an average throughput of about 700KBytes/sec on the iBook when viewing a DVD. I used both VLC and DVD Player with good results.
    With my new MacBook, I can't view my DVD files. 802.11g network transfer rates to the MB (indicated by MenuMeters and by Activity Monitor) vary rapidly from a high of about 1.1 MBytes/sec to 20 KBytes/sec. Movies stall, skip, etc.
    Simple file copies from one system to another are also much slower with the MacBook - an average of ~100KBytes/sec vs. ~ 1.5 MBytes/sec with my old iBook. In short, the MacBook is dog-slow in file transfers from the other machines compared with my old iBook when using the wifi connection, with no change to the network infrastructure in going from the old laptop to the new. I would like to fix this.
    My AEB is set up in bridge mode (simple access point) with WPA2 security. All three Macs are completely current with latest updates, as is the Snow AEB. The MB has 4 bars of signal strength. Slow file transfer problem does not change when moving the MB to or from the AEB.
    Curiously, when I download a large file (like the Intel 10.4.9 combo update), the MB shows a steady ~800KBytes/sec download speed, with none of the speed variation it shows with file transfers from either the Mini or the G5. File transfers to/from the MB to either of the other Macs are very slow.
    Both the Mini and the G5 have Airport cards: when I switch them from wired Ethernet LAN to wifi LAN, they transfer files between each other at ~ 2MBytes/sec - about what you'd expect from an 802.11g protocol. So the slow file transfer doesn't seem to be due to the AEB, it seems to be specific to the MacBook. When I connect the MB using its hardware Ethernet port, files transfer just as fast as the other systems.
    I have tried these measures, without effect on the problem:
    - power off/restart of every component in the system;
    - changing the AEB to an open network mode;
    - changing the MB from static IP to DHCP;
    - toggling IPv6 on/off;
    - running no applications other than Finder on all systems;
    Activity Monitor on the MB doesn't show anything sucking up CPU cycles during file transfers. I have plenty of RAM. The only thing I've changed in the network is the swap of the iBook for the MacBook.
    Can anyone suggest what else I can try to make acquisition of this nice shiny MacBook a step forward, rather than a step back? Thank you!
    G5 DP 1.8, Mini CD1.83 GHz, MacBook C2D,2GHz   Mac OS X (10.4.9)  
    G5 DP 1.8, Mini 1.83 GHz, G4 iBook   Mac OS X (10.4.8)  
    G5 DP 1.8, Mini 1.83 GHz, G4 iBook   Mac OS X (10.4.8)  

    Hi,
    Did you want to use the Live Migrations for that?
    We recommend that you configure separate dedicated networks with gigabit or faster speed for live migration traffic and cluster communication, and these networks should be separate from the network used by the management operating system, and from the network
    used by the virtual machines.
    For more and detail information, please refer to:
    http://technet.microsoft.com/en-us/library/ff428137(WS.10).aspx
    Regards.
    Vivian Wang

  • Problems with .ARW files and auto toning

    problems with .ARW files and auto toning
    let me try to explain this because this has happened in past and never found a way to resolve but i lived with it
    now that I have a Sony A7R the problem is more serious
    Firstly i take pride it making the picture happen all in camera, i use DRO lvl 5 to get enough light, like when i'm shooting at dusk. DRO its like doing HDR but in a single file, it lightens the darks. in my camera i'm happy with results
    but when I upload them to lightroom, they come out near black.
    allow me to explain
    lets say I import 100 images
    i double check my preferences and everything is UNCHECKED when it comes to importing options, there is no auto toning, nothing.
    as the images import i see a preview in the thumbnail which looks fine.
    i double click on one to enlarge it, hence leave grid view.
    for a brief 1 or 2 seconds, i see the full image in all its glory but than lightroom does something funny, it darkens the image
    one by one as it inspects each image, if it was a DRO image it makes it too dark.
    to make this clear, the image is perfect as it was in the beginning but after a few seconds lightroom for some reason thinks it needs to correct it.
    how to prevent lightroom from doing this, i want the image exactly as it is, why must lightroom apply a correction>?
    i think it has to do something with interpreting the raw file and lightroom applies its own algorithm.
    but here is what i dont get.....before lightroom makes the change i'm able to witness the picture exactly as it was taken and want it unchanged..
    now i have to tweak each file or find a profile for it which is added work.
    any ideas how to prevent lightroom from ruining my images and just leave them as they were when first detected...
    there are 2 phases...one is when it originally imports and they look fine
    second is scanning each image and applying some kind of toning which darkens it too much.
    thanks for the help

    sorry thats the auto reply message from yahoo email.
    i've disabled it now
    thing is, there is no DRO jpg to download from the camera
    its only ARW. so my understanding is when i use DRO setting, the camera makes changes to the ARW than lightroom somehow reads this from the ARW.
    but then sadly reverts it to no DRO settings.
    because i notice if i take normal picture in raw mode its dark but if i apply dro to it, it comes out brighter, yet when i d/l the image from camera to lightroom, which is an ARW - there are no jpgs. lightroom decides to mess it up
    so in reality there is no point in using DRO because when i upload it lightroom removes it.
    is there a way to tell lightroom to preserve the jpg preview as it first sees it.
    its just lame, picture appears perfect...than lightroom does something, than bam, its ruined,.
    what do i need to do to prevent lightroom from ruining the image? if it was good in the first place.

  • Problems with compressing  files with right hand click. it does not work.

    Problems with compressing files with right hand click.
    I am using the compress function in the Mac OS (File > Compress XX) from time to time. Today it does not work anymore. OS 10.5.6
    I get a message: The content list cannot be created for compressing.
    I tried it with files and folders and keep getting this message. Anybody any idea as to how to fix this

    Thanks I love my macbook!!!!
    I also got further problems such as copy-paste not working etc.
    so I fixed it just this morning by running Applejack 1.5 and am back up running noticing your post.
    thanks for helping though!

  • Help with add file name problem with Photoshop CS4

    Frustrating problem: Help with add file name problem with Photoshop CS4. What happens is this. When I am in PS CS4 or CS3 and run the following script it runs fine. When I am in Bridge and go to tools/photoshop/batch and run the same script it runs until it wants interaction with preference.rulerunits. How do I get it to quit doing this so I can run in batch mode? Any help is appreciated. HLower
    Script follows:
    // this script is another variation of the script addTimeStamp.js that is installed with PS7
    //Check if a document is open
    if ( documents.length > 0 )
    var originalRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.INCHES;
    try
    var docRef = activeDocument;
    // Create a text layer at the front
    var myLayerRef = docRef.artLayers.add();
    myLayerRef.kind = LayerKind.TEXT;
    myLayerRef.name = "Filename";
    var myTextRef = myLayerRef.textItem;
    //Set your parameters below this line
    //If you wish to show the file extension, change the n to y in the line below, if not use n.
    var ShowExtension = "n";
    // Insert any text to appear before the filename, such as your name and copyright info between the quotes.
    //If you do not want extra text, delete between the quotes (but leave the quotes in).
    var TextBefore = "Lower© ";
    // Insert any text to appear after the filename between the quotes.
    //If you do not want extra text, delete between the quotes (but leave the quotes in).
    var TextAfter = " ";
    // Set font size in Points
    myTextRef.size = 10;
    //Set font - use GetFontName.jsx to get exact name
    myTextRef.font = "Arial";
    //Set text colour in RGB values
    var newColor = new SolidColor();
    newColor.rgb.red = 0;
    newColor.rgb.green = 0;
    newColor.rgb.blue = 0;
    myTextRef.color = newColor;
    // Set the position of the text - percentages from left first, then from top.
    myTextRef.position = new Array( 10, 99);
    // Set the Blend Mode of the Text Layer. The name must be in CAPITALS - ie change NORMAL to DIFFERENCE.
    myLayerRef.blendMode = BlendMode.NORMAL;
    // select opacity in percentage
    myLayerRef.opacity = 100;
    // The following code strips the extension and writes tha text layer. fname = file name only
    di=(docRef.name).indexOf(".");
    fname = (docRef.name).substr(0, di);
    //use extension if set
    if ( ShowExtension == "y" )
    fname = docRef.name
    myTextRef.contents = TextBefore + " " + fname + " " + TextAfter;
    catch( e )
    // An error occurred. Restore ruler units, then propagate the error back
    // to the user
    preferences.rulerUnits = originalRulerUnits;
    throw e;
    // Everything went Ok. Restore ruler units
    preferences.rulerUnits = originalRulerUnits;
    else
    alert( "You must have a document open to add the filename!" );

    you might want to try the scripting forum howard:
    http://www.adobeforums.com/webx?13@@.ef7f2cb

Maybe you are looking for