Half-Retirean's Lazy Life Diary / ダラダラ余生日記

最近思ったこと: やりたいことだけやるって幸せなことだ

ホーム 連絡をする 同期する ( RSS 2.0 ) Login
投稿数  984  : 記事  4  : コメント  42107  : トラックバック  277

ニュース

My Website

初心者向けのサイトです。

C# と VB.NET の入門サイト

最近のできごと

暇人28号FX

Sponsored Link1

Sponsored Link2

Archive

書庫

System.IO.Directory.Existsについて [dobon.net] からの引用

この際に、System.IO.Directory.Existsに不正なパスが入力されていてもtrueになっており困っています。
どういう事か言うと
"C:\"=true
"C:\ \ \ \"でもtrueになってしまいます。
また、System.IO.Directory.GetFilesでも"C:\ \ \ \"は問題無く通過してしまい、"C:\ \ \ \pagefile.sys"という値が帰ってきます。

以前スペースのあるパスを正しく生成できないとか判別できないという問題がありましたが、他にもいろいろとあるのですよね。

System.IO.FileInfo クラスでは整形できているので『Windows 的にはこういうパスは不正でないのか?』とも思いましたが、実際にそのパスを利用しようとするとエラーになる不一致がある以上違うような気がします。パスを入力して何かをするようなアプリケーションではパスのチェックは当然しますが、これでは厳密でなくなってしまいます。意地悪なユーザーさんだとこういうテストをしてくるところが恐ろしい。(こういうユーザーは例外を発見すると子供のように喜ぶw)

とはいえ、厳密に Exists メソッドでチェックした直後にファイル処理を実行したとしても、その間に変更がないと保証できないのでファイルの処理では必ず例外処理を実装することが必須です。逆に言えば、上記のような稀な不都合もそこで吸収できるというわけです。よく Exists メソッドでチェック後に何ら例外処理をいれずにファイル処理をしているコードがありますが、ここで使わなくていつ例外処理を使うのかと小一時間(ry

特定のメソッドで自動でブロックが生成されるような言語仕様があれば Java の throws のように促せられるなぁなんて妄想したことがあります。これに限らず属性 (でなくてもいいけど) と IDE の自動生成コードとの連携にもっと容易に手を加えられると、グループ開発でのルールが強制されて楽になれそうな気がします。

投稿日時 : 2008年4月30日 11:27

コメント

# re: System.IO.File | Directory クラスの動き 2008/04/30 11:51 れい
プログラミングの話は本当にひさしぶりだなぁ。

# re: System.IO.File | Directory クラスの動き 2008/04/30 12:11 じゃんぬねっと
ネタ中心の Blog な上に、Blog の主が最近プログラミングしていないからしょうがないんですよ。

# re: System.IO.File | Directory クラスの動き 2008/04/30 13:16 れい
> Blog の主が最近プログラミングしていないからしょうがないんですよ

上流工程なのですか。
人が足りないなら上流の人間を下流に…

# re: System.IO.File | Directory クラスの動き 2008/04/30 15:14 ネタ好き未記入
>ネタ中心の Blog な上に、Blog の主が最近プログラミングしていないからしょうがないんですよ。

それはお気の毒に。私なんか1週間もプログラミングしないと禁断症状がおきて手が震えてしまいます。
それに、上流下流と分ける日本の風習がこの業界を駄目にしていると思います。
私は常に両方やってきましたが、何時も盗られるからいっそうの事どちらかにして欲しいと思ったことありますがねw

# re: System.IO.File | Directory クラスの動き 2008/04/30 15:30 ネタ好き未記入
でも一つ問題なのが、throwを書く場所が適切かどうか判定できない事ですよねw
馬鹿な人がやたらめったら意味なくthrowしてもそれをコンパイルエラーに出来ない。今の開発環境は文法エラーには強いのですが、そういった論理的エラーには弱いんですよね・・・


# re: System.IO.File | Directory クラスの動き 2008/04/30 16:53 ネタ好き未記入
そうだいい事思いついた、新人が入ったら鍛えるという名目でじゃんぬさんが一緒に下流もやればいい。
そして嫌になったら上流へ行く。
これぞいいとこ取り!
私ならば理由をつけて両方参加すると思う(笑)

# re: System.IO.File | Directory クラスの動き 2008/04/30 21:49 ぐっちょん
>(こういうユーザーは例外を発見すると子供のように喜ぶw)
うわー最近経験しましたw

こんなん普通の使い方してたら絶対出てこないだろっていうものをズバッと指摘してくるんですよねぇ
なんかいい対処法ないかなぁ?

私には時間かけて無かったことにするぐらいしか思いつかないです。

# re: System.IO.File | Directory クラスの動き 2008/05/02 1:41 ネタ好き未記入
?!いつの間にかニュース欄が本の紹介となっている!ずっとネタだったので逆に面白い。
私はC++/CLIが不得意なのでお金が工面できたら買おうと思います。ただ、どうやったら工面できるのかが課題ですが(笑)

# re: System.IO.File | Directory クラスの動き 2008/05/02 4:21 渋木宏明(ひどり)
>ここで使わなくていつ例外処理を使うのかと

まったく。

この手以外でロジック中で例外握りつぶしたらコロシます>じぶん


# re: System.IO.File | Directory クラスの動き 2008/05/02 7:35 ネタ好き未記入
日どりさん怖い。きっと職場で鬼軍曹とよばれていますねw
私なんて優しいから鴨と呼ばれていましたよ。

# re: System.IO.File | Directory クラスの動き 2008/05/02 12:05 渋木宏明(ひどり)
カトラーよりは怒りっぽくないと思いますw

# pjIvfpxCnISKD 2014/07/19 10:56 http://crorkz.com/
ZDOmhH I truly appreciate this article.Really looking forward to read more. Awesome.

# YJtEGYULeHaSPA 2014/08/02 11:24 http://crorkz.com/
Ran2DR I really liked your article.Really looking forward to read more. Awesome.

# LeODEVqozdsZYOm 2014/08/07 11:37 http://crorkz.com/
LyQbjP Major thankies for the blog.Thanks Again. Awesome.

# cnZWFmcRTG 2015/01/11 13:00 varlog
gDREbL http://www.FyLitCl7Pf7kjQdDUOLQOuaxTXbj5iNG.com

# cpvRQYBRtRaQxlJbAfo 2015/01/26 11:11 Johnie
I've got a full-time job http://www.medicalreformgroup.ca/newsletters/ how many mg of acetaminophen in regular tylenol � Microsoft rose 96 cents, or 2.7 percent, to $35.66, after the company announced a major reorganization. The world's largest software maker has been struggling with a steady decline in PC demand as people turn to tablets and other mobile devices.


# sArhGCruMiwcRC 2015/01/27 17:20 Rupert
What are the hours of work? http://www.webface.ie/our-advantages.html discount imovane These may seem strange questions for a column devoted mostlyto controversies in public policy and economics, but newspaperstoday are a declining industry comparable to the steel andshipbuilding industries in the 1980s, and employ even morepeople at higher wages. Newspapers are therefore of greateconomic significance, not to mention their importance todemocracy.


# eVXEHqAVnwQiTNM 2015/01/27 17:20 Courtney
I'm not sure http://kyoorius.com/publications/ bromazepam mylan With this win, UCLA (9-2, 6-2 in Pac-12) secured a place in the Pac-12 Championship Game and their first 9-win season since 2005. Who exactly the Bruins would be playing in that game would be determined by their game the next week. In a very peculiar scheduling quirk, the final game of UCLA's regular season was against Stanford at the Rose Bowl. With a win over Stanford, UCLA was lined up for a game at Oregon (barring an extremely unlikely upset of the Ducks by Oregon State) and with a loss, UCLA was headed to Palo Alto for a rematch with the Cardinal.


# aTppzVyONPAnzFjyQt 2015/01/27 17:20 Jenna
Punk not dead http://www.cleanenergyconsultancy.co.uk/training/workshops/ zopiclone 7.5mg not working "It's like New York City at lunch time here. We are reallybusy," said marina manager Steve Penny. "We are doing everythingwe can to make room for 4 to 6 feet of water. Anything we canmove, we get out."


# WgmcmPALlvsHob 2015/02/06 0:05 Stewart
very best job http://artist-how-to.com/studio/portraits/ cash advance plymouth SIR – Geoffrey Simms (Letters, July 9) quotes capacity approaching 100 per cent at Paddington and 80 per cent at Liverpool Street. That is precisely why we have the building of the biggest infrastructure project in Europe – Crossrail.


# jKXasblXcZjXeVkaegg 2015/02/06 19:29 Micah
Where are you from? http://www.wonderbra.ca/products-page/ efectos secundarios del tenormin 100 mg After Ovechkin tied it with a power-play goal, Kane sent a wrist shot past Holtby to make it 2-1 at 11:06. Kane won the Conn Smythe Trophy as playoff MVP when the Blackhawks made their run to the championship.


# pUwVKBGKAWVXZX 2015/02/07 23:35 Augustine
In a meeting http://www.green-events.co.uk/about.html Vytorin 10 Mg For the most part, the terrain over which Mars rovers travel — including the most recent Curiosity mission — is relatively benign, consisting mostly of flat, firm surfaces. But occasionally, rovers encounter more challenging environments, such as steep dunes covered in fine, loose soil.


# XzxvbxiaeQ 2015/02/08 17:31 Hailey
We used to work together http://atecuccod.com/index.php/aszf get a commercial loan With his upswept wig and his retro 1970s wardrobe, Michael Douglas' transformation into Liberace is complete. The 67-year-old actor was a dead-ringer for the late '70s icon as he stepped out in full costume while shooting HBO's upcoming television movie, "Behind the Candelabra." Directed by Steven Soderbergh, the biopic follows Liberace's ill-fated love affair with Scott Thorson, played by Matt Damon.


# rQkhqFExTOtOmKavp 2015/02/08 17:31 Floyd
I live here http://www.sporttaplalkozas.com/sporttaplalkozas/sporttaplalkozas-program online installment loans direct lenders bad credit �It didn�t feel good, especially in the rough. That rough was dense and it was lush,� he said. �You go from whatever it is, let�s say 100-some-odd miles an hour to virtually zero. I really couldn�t get through it. And it put a lot of torque on it and it hurt. Conversely, just stay out of the damn thing. Put it in the fairway and put it on the green and make your putts. It�s not like I was drawing bad lies on those tee boxes.�


# GCDVSluLvlahsM 2015/02/10 1:59 Andrea
Withdraw cash http://www.groteverhalen.info/index.php/agenda cash advance hilliard fl When Buddy could no longer care for her on his own, arrangements were made for Joanie at an assisted-living home in Louisville, Ky. Buddy sold their farm in Anderson County and moved to Shelbyville to be closer to her.


# HJbolZPcLKhJtLd 2015/02/10 8:43 Marcus
The United States http://www.milliput.com/about.html Aciclovir Tablets Uk Grantham, 74, recalls being knocked unconscious five times in one season with the Jets. "Usually the trainers would leave it up to the player, even though we had team doctors and orthopedic men on the sidelines," he said. "Most times the trainers took our word."


# DAZSwfbPcO 2015/02/10 8:44 Makayla
I work here http://www.milliput.com/about.html Aciclovir Cold Sore Cream REPRESENTATIVE DEBBIE STABENOW: Can we expect that after the company had adopted Smithfield's excellent technology and practices, they will increase exports to Japan, our largest export market in competition with U.S. products?


# FZIzMALOMsqZaYfF 2015/02/10 8:44 Aubrey
I'm unemployed http://www.testwall.com/products/ Generic Fenofibrate So commissioner Bud Selig suspends Braun now for the rest of the season. And a year and a half after that touchdown dance in Arizona, when Braun essentially made a mockery of baseball�s drug-testing program, here is the statement that he issued on Monday:


# LXjAcHbwKHFEBMam 2015/02/10 8:44 Ronnie
US dollars http://broadcastmedia.co.uk/communications-training Cheap Famvir There are other conversations that should be just as uncomfortable: How can parents promote hero worship of athletes when they know so little about the person in the uniform? Why are we so quick to idolize someone based simply on their ability to throw or catch a ball?


# ZPmpXFVIYtEacoNtnQj 2015/02/11 10:19 Stacey
Is there ? http://www.groteverhalen.info/index.php/agenda esop loan Catalans gather in a bid to create a 250-mile human chain, part of a campaign for independence from Spain during Catalonia National Day, or Diada, on Passeig de Gracia in Barcelona, on September 11, 2013. Independence-seeking Catalans marshalled their forces today to make a human link they say will stretch across 86 cities, towns and villages along the coast of the northeastern region on the Mediterranean, passing landmarks such as the Sagrada Familia basilica in Barcelona and the city's Camp Nou football stadium.


# cDiBKFRlKoQBECBg 2015/02/24 7:16 Dallas
Jonny was here http://www.streamsweden.com/support/ generic inderal Following the first performance at the Argyll Rooms by conductor Sir George Smart, the work was criticised for its length and "diffuseness", with one critic branding it "an unequal work, abounding more in noise, eccentricity, and confusion of design".


# wHifzSKrymxd 2015/02/24 7:16 Jamie
I came here to study http://www.streamsweden.com/support/ buy cheap inderal Bezo's pockets seem plenty deep enough, even for the Post, which had an operating loss of $54 million last year, though that was down from a loss of nearly $200 million in 2008 and $175 million in 2009.


# NlkrIaLSvJBWhY 2015/02/24 7:16 Markus
I love the theatre http://www.wisconsinplanners.org/requestsforproposals.html propranolol 40 mg. tablets Established to enforce the 1997 Chemical Weapons Convention, the OPCW has an annual budget of under $100 million and less than 500 staff. It does not have the manpower to carry out the task without significantly increasing resources.


# ccjSOgfVfth 2015/02/24 7:16 Harris
this is be cool 8) http://www.streamsweden.com/foretaget/ propranolol 40 mg how long does it last CFIUS experts largely believe the deal will be approved.Smithfield would still be subject to U.S. food safetyrequirements, and the company has said the merger is driven bygrowing pork demand in China, not a strategy to export pork tothe United States.


# LomgVYagHQwLIAgAG 2015/02/25 10:30 Audrey
Whereabouts are you from? http://www.orthopaedic-institute.org/find_us.html kegunaan obat motilium 10mg The wide-sweeping financial reform law known as Dodd-Frank calls for those who provide investment advice to municipalities to register with the federal government and to adhere to a fiduciary standard where the municipalities' interests are put first.


# nImzBYkafoHa 2015/02/25 10:30 Sarah
Yes, I love it! http://www.alexisfacca.com/chemistry/ Telmisartan Online "This acquisition fits our strategy excellently, generatingimmediate additional value through synergies of assets andincreasing production and cash flow attractively," PacificRubiales Chief Executive Ronald Pantin said in the filing.


# IIzmIIfAkaYNRFE 2015/02/26 13:47 Modesto
A financial advisor http://www.nude-webdesign.com/managed-hosting/ abilify discount coupons �We based our dramatization around two 911 calls. Is it disturbing? You bet it is,� said Ladd Everitt, Coalition to Stop Gun Violence communications director. He told MSNBC, �It�s heartbreaking, and it should upset anyone who has basic human decency.�


# qeyTkanaOebA 2015/02/26 13:47 Sidney
Photography http://www.nude-webdesign.com/testimonials/ abilify 2013 commercial William Cannon, a longtime archaeologist for the U.S. Bureau of Land Management who discovered the petroglyphs at Long Lake in Oregon, brought the Nevada site to Hattori's attention years ago. He said they bore similarities to petroglyphs at nearby Winnemucca Lake, and Hattori began connecting the dots.


# YdUCILBkXqqiUvMxiq 2015/02/28 0:02 Andres
What do you study? http://version22.com/about/ latanoprost generic for xalatan Under the provisions of the Protection of Life During Pregnancy Act 2013, there are reporting mechanisms in place so that, at the end of each year, figures on the number of abortions will be made available.


# ZYpvIUDfnAyTyTohD 2015/02/28 0:03 Jarvis
I'm on work experience http://www.muruniiduk.ee/products Tricor 145mg Davutoglu said the selection was not politically motivated, and that the Chinese offer had met Turkey's primary demands of price and the ability to place much of the production in Turkey, although he reiterated that the decision was not final.


# NalRPSPjAHyjXsmtUC 2015/02/28 0:03 Camila
Very funny pictures http://www.europanova.eu/category/actualite/ generic form of bimatoprost Sales of lads' mags have dropped dramatically in the past year, although online versions have significantly propped up readerships. Official ABC figures show that sales of Nuts, published by IPC, dropped 34.8% in the first six months of the year, when an average of 58,781 copies were sold per month, with sales of Zoo down 23.1% in the same period.


# QnNUfpzTdyxy 2015/04/07 16:09 Boris
Are you a student? http://www.europanova.eu/entreprendre-leurope/ bimatoprost overnight online Police and the FBI expanded their search today to more vacant homes and empty lots near the neighborhood where Madison frequented, after he led investigators to believe he may have been influenced by Ohio serial killer Anthony Sowell, Norton said.


# スーパーコピー時計N級品専門店 2016/02/16 3:53 h0av7wf239
http://www.msnbrand.com/goods-copy-4026.html
エルメス ケリー激安}}}}}}

Post Feedback

タイトル
名前
Url:
コメント: