Results 1 to 2 of 2

Thread: java.io.File.getCanonicalPath() exception in C#.net....

  1. #1

    Thread Starter
    Hyperactive Member koolprasad2003's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    443

    Question java.io.File.getCanonicalPath() exception in C#.net....

    HI
    i have create a project having VSJLIB reference in it

    when i have code it as follows

    Code:
    <pre> public void CreateZipFile(string sPath)
       {
         FileOutputStream stream1 = null;
         ZipOutputStream stream2 = null;
         if (System.IO.File.Exists(sPath))
         {
    	FileInfo info2 = new FileInfo(sPath);
            stream1 = new FileOutputStream(sPath.Replace
                                          (info2.Extension, ".zip"));
    	stream2 = new ZipOutputStream(stream1);
    			this.ZipOneFile(stream1, stream2,  sPath);
         }
         else if (Directory.Exists(sPath))
         {
    	stream1 = new FileOutputStream(sPath + ".zip");
    	stream2 = new ZipOutputStream(stream1);
    	DirectoryInfo info1 = new DirectoryInfo(sPath);
    	this.ZipDirectory(stream1, stream2, info1, sPath);
         }
         stream2.close();
         stream1.close();
         stream2.flush();
         stream1.flush();
        }
    
        private void CopyStream(FileInputStream src, ZipOutputStream
                                                                 dest)
        {
    	InputStreamReader reader1 = new InputStreamReader(src);
    	OutputStreamWriter writer1 = new OutputStreamWriter(dest);
    	while (reader1.ready())
    	{
    	  writer1.write(reader1.read());
    	}
    	writer1.flush();
        }
    		
        /*ZipDirectory Method zips the entire directory*/
        private void ZipDirectory(FileOutputStream fos, ZipOutputStream 
                                 zos, DirectoryInfo di, string SRootDir)
        {
    	FileInfo[] infoArray2 = di.GetFiles();
    	foreach (FileInfo info2 in infoArray2)
    	{
               ZipEntry entry1 = new ZipEntry
                   (info2.FullName.Substring(SRootDir.LastIndexOf(@"\")));
    	   entry1.setMethod(8);
    	   zos.putNextEntry(entry1);
    	   FileInputStream stream1 = new FileInputStream
                                           (info2.FullName);
           	   this.CopyStream(stream1, zos);
    	   zos.closeEntry();
    	   stream1.close();
    	}
    	DirectoryInfo[] infoArray1 = di.GetDirectories();
    	foreach (DirectoryInfo info1 in infoArray1)
    	{
    	   this.ZipDirectory(fos, zos, info1, SRootDir);
    	}
         }
    </pre>
    but when i run the code it gives me excetion

    <big>java.io.File.getCanonicalPath() </big>

    what should i do to run the code ???

    any suggesations ???
    Last edited by mendhak; Aug 11th, 2009 at 01:26 AM.
    MCP, MCTS, Microsoft MVP [Asp.Net/IIS]

    For more .NET development tips visit .NET Tips

    If the post is useful then please Rate it

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: java.io.File.getCanonicalPath() exception in C#.net....

    What's the exception?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width