473,386 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I want to create function that create files and check if is exists or not

Expand|Select|Wrap|Line Numbers
  1.  File f = new File("C:\\TEST");
  2.     try{
  3.         if(f.exists()==false){
  4.             f.mkdir();
  5.         System.out.println("Directory Created");
  6.         }
  7.         else{
  8.         System.out.println("Directory is not created");
  9.         }
  10.     }catch(Exception e){
  11.         e.printStackTrace();
  12.        }

and i have this error : illegal start of type in the try statement ...

please help my friends
Nov 14 '12 #1
2 2279
Hi


Expand|Select|Wrap|Line Numbers
  1. var dir = new DirectoryInfo(@"d:\Temp");
  2.             var file = new FileInfo(Path.Combine(dir.FullName, "file.txt"));
  3.             if (!file.Exists) // you may not want to overwrite existing files
  4.             {
  5.                 using (Stream stream = file.OpenWrite())
  6.                 using (StreamWriter writer = new StreamWriter(stream))
  7.                 {
  8.                     writer.Write("saeid");
  9.                 }
  10.             }
Nov 14 '12 #2
temp Folder is Example folder that Exists in Drive d
Nov 14 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: A.M. de Jong | last post by:
Can I dynamically (from a stored procedure) generate a create table script of all tables in a given database (with defaults etc) a create view script of all views a create function script of all...
5
by: Thomas LeBlanc | last post by:
I copied an example from the help: CREATE FUNCTION somefunc() RETURNS integer AS ' DECLARE quantity integer := 30; BEGIN RAISE NOTICE ''Quantity here is %'', quantity; -- Quantity here is 30...
1
by: Barbara Lindsey | last post by:
I am a postgres newbie. I am trying to create a trigger that will put a copy of a record into a backup table before update or delete. As I understand it, in order to do this I must have a...
1
by: Frank Neubert | last post by:
Hello! I work with "IBM DB 2 Universal Database for Windows NT" Version 6. I want to create Function, which are using in a Queries. I don't want to use external function. I want to create a...
1
by: AmitK | last post by:
is it possible to create a myi, myd file for mysql using a C program. I am using Stata that is written in C API, and I want to write the data out to MYSQL database. Using ODBC and loading the data...
0
by: TOI DAY | last post by:
Hi All, I want to create an ISO image, is there a way in c# to do that? I also want to read the files from the ISO Image then store it in the database. Is there an API for this? Thanks in...
0
by: . | last post by:
http://daviderognoni.blogspot.com?locawapp - MAIN NEWS =========== * add thread * add "Request" object * new "locawapp_main" function * fixed files.py
0
by: bog39 | last post by:
We have z/os and DB/2 V. 8 running. I try to create a new UDF using the command CREATE FUNCTION: CREATE FUNCTION CNGETADR (INTEGER) RETURNS CHAR(50) EXTERNAL NAME CNADR001 ...
7
by: olav78 | last post by:
create database test if not exists. Someone know how to do this in postgreSQL?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.