Your code with some comments :
def Save(self):
filename = "record.txt"
data = "{0}:{1}".format(self.Level,self.Name)
isf = IsolatedStorageFile.GetUserStoreForApplication()
try:
isfs = IsolatedStorageFileStream(filename, FileMode.Create, isf)
try: # These try is useless....
sw = StreamWriter(isfs)
try:
sw.Write(data)
finally:
sw.Dispose()
finally: # Because next finally statement (isfs.Dispose) will be always executed
isfs.Dispose()
finally:
isf.Dispose()
For StreamWrite, you can use a with statment (if your object as __enter__ and _exit__ methods) then your code will looks like :
def Save(self):
filename = "record.txt"
data = "{0}:{1}".format(self.Level,self.Name)
isf = IsolatedStorageFile.GetUserStoreForApplication()
try:
isfs = IsolatedStorageFileStream(filename, FileMode.Create, isf)
with StreamWriter(isfs) as sw:
sw.Write(data)
finally:
isf.Dispose()
and StreamWriter in his __exit__ method has
sw.Dispose()